Dani commited on
Commit
be8b9f6
1 Parent(s): 845600f

spanishVersion

Browse files
Files changed (2) hide show
  1. app.py +43 -0
  2. requirements.txt +8 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ import gradio as gr
4
+ from transformers import pipeline
5
+ import tempfile
6
+ import os
7
+
8
+ # with open("../../token.txt", "r") as file:
9
+ # token = file.readline().strip()
10
+ #
11
+ #
12
+ # login(token=token, add_to_git_credential=True)
13
+
14
+ pipe = pipeline(model="dacavi/whisper-small-es")
15
+
16
+ def transcribe_video(video_url):
17
+ # Download video and extract audio
18
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=True) as temp_audio:
19
+ # os.system(f"yt-dlp -o {temp_audio.name} -x --audio-format wav {video_url}")
20
+ os.system(f"yt-dlp -o audioSample.wav -x --audio-format wav {video_url}")
21
+
22
+ print("Downloaded audio:", temp_audio.name)
23
+
24
+
25
+ # Transcribe audio
26
+ text = pipe("audioSample.wav")["text"]
27
+
28
+ # Clean up temporary files
29
+ os.remove("audioSample.wav")
30
+
31
+
32
+ return text
33
+
34
+ iface = gr.Interface(
35
+ fn=transcribe_video,
36
+ inputs="text",
37
+ outputs="text",
38
+ live=True,
39
+ title="Video Transcription",
40
+ description="Paste the URL of a video to transcribe the spoken content.",
41
+ )
42
+
43
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ transformers
2
+ torch
3
+ tensorflow
4
+ moviepy==1.0.3
5
+ ffmpeg
6
+ ffprobe
7
+ yt-dlp
8
+ pydub