Spaces:
Runtime error
Runtime error
Commit
·
1c4db4e
1
Parent(s):
0f2d4df
Update app.py
Browse files
app.py
CHANGED
@@ -104,7 +104,7 @@ def Transcribe(audio="temp_audio.wav"):
|
|
104 |
RemoveAllFiles()
|
105 |
return (t_text, ({ "data": [{"speaker": speaker, "text": text} for speaker, text in conversation]}))
|
106 |
|
107 |
-
def AudioTranscribe(audio, retries=5):
|
108 |
if retries:
|
109 |
try:
|
110 |
subprocess.call(['ffmpeg', '-i', audio,'temp_audio.wav'])
|
@@ -117,7 +117,7 @@ def AudioTranscribe(audio, retries=5):
|
|
117 |
else:
|
118 |
raise gr.Error("There is some issue ith Audio Transcriber. Please try again later!")
|
119 |
|
120 |
-
def VideoTranscribe(video, retries=5):
|
121 |
if retries:
|
122 |
try:
|
123 |
command = f"ffmpeg -i {video} -ab 160k -ac 2 -ar 44100 -vn temp_audio.wav"
|
@@ -132,7 +132,7 @@ def VideoTranscribe(video, retries=5):
|
|
132 |
raise gr.Error("There is some issue ith Video Transcriber. Please try again later!")
|
133 |
return Transcribe()
|
134 |
|
135 |
-
def YoutubeTranscribe(URL, retries = 5):
|
136 |
if retries:
|
137 |
if "youtu" not in URL.lower():
|
138 |
raise gr.Error(f"{URL} is not a valid youtube URL.")
|
@@ -160,17 +160,17 @@ def YoutubeTranscribe(URL, retries = 5):
|
|
160 |
|
161 |
ut = gr.Interface(
|
162 |
fn=YoutubeTranscribe,
|
163 |
-
inputs=[gr.Number(label="Number of Speakers", placeholder="2"), gr.Textbox(label="Name of the Speakers (ordered by the time they speak and
|
164 |
outputs=[gr.Textbox(label="Transcribed Text", lines=15), gr.JSON(label="Transcribed JSON")]
|
165 |
)
|
166 |
vt = gr.Interface(
|
167 |
fn=VideoTranscribe,
|
168 |
-
inputs='video',
|
169 |
outputs=[gr.Textbox(label="Transcribed Text", lines=15), gr.JSON(label="Transcribed JSON")]
|
170 |
)
|
171 |
at = gr.Interface(
|
172 |
fn=AudioTranscribe,
|
173 |
-
inputs='audio',
|
174 |
outputs=[gr.Textbox(label="Transcribed Text", lines=15), gr.JSON(label="Transcribed JSON")]
|
175 |
)
|
176 |
|
|
|
104 |
RemoveAllFiles()
|
105 |
return (t_text, ({ "data": [{"speaker": speaker, "text": text} for speaker, text in conversation]}))
|
106 |
|
107 |
+
def AudioTranscribe(NumberOfSpeakers=None, SpeakerNames="", audio, retries=5):
|
108 |
if retries:
|
109 |
try:
|
110 |
subprocess.call(['ffmpeg', '-i', audio,'temp_audio.wav'])
|
|
|
117 |
else:
|
118 |
raise gr.Error("There is some issue ith Audio Transcriber. Please try again later!")
|
119 |
|
120 |
+
def VideoTranscribe(NumberOfSpeakers=None, SpeakerNames="", video, retries=5):
|
121 |
if retries:
|
122 |
try:
|
123 |
command = f"ffmpeg -i {video} -ab 160k -ac 2 -ar 44100 -vn temp_audio.wav"
|
|
|
132 |
raise gr.Error("There is some issue ith Video Transcriber. Please try again later!")
|
133 |
return Transcribe()
|
134 |
|
135 |
+
def YoutubeTranscribe(NumberOfSpeakers=None, SpeakerNames="", URL, retries = 5):
|
136 |
if retries:
|
137 |
if "youtu" not in URL.lower():
|
138 |
raise gr.Error(f"{URL} is not a valid youtube URL.")
|
|
|
160 |
|
161 |
ut = gr.Interface(
|
162 |
fn=YoutubeTranscribe,
|
163 |
+
inputs=[gr.Number(label="Number of Speakers", placeholder="2"), gr.Textbox(label="Name of the Speakers (ordered by the time they speak and separated by comma)", placeholder="If Speaker 1 is first to speak followed by Speaker 2 then -> Speaker 1, Speaker 2"), gr.Textbox(label="Youtube Link", placeholder="https://www.youtube.com/watch?v=GECcjrYHH8w"),],
|
164 |
outputs=[gr.Textbox(label="Transcribed Text", lines=15), gr.JSON(label="Transcribed JSON")]
|
165 |
)
|
166 |
vt = gr.Interface(
|
167 |
fn=VideoTranscribe,
|
168 |
+
inputs=[gr.Number(label="Number of Speakers", placeholder="2"), gr.Textbox(label="Name of the Speakers (ordered by the time they speak and separated by comma)", placeholder="If Speaker 1 is first to speak followed by Speaker 2 then -> Speaker 1, Speaker 2"), 'video'],
|
169 |
outputs=[gr.Textbox(label="Transcribed Text", lines=15), gr.JSON(label="Transcribed JSON")]
|
170 |
)
|
171 |
at = gr.Interface(
|
172 |
fn=AudioTranscribe,
|
173 |
+
inputs=[gr.Number(label="Number of Speakers", placeholder="2"), gr.Textbox(label="Name of the Speakers (ordered by the time they speak and separated by comma)", placeholder="If Speaker 1 is first to speak followed by Speaker 2 then -> Speaker 1, Speaker 2"), 'audio'],
|
174 |
outputs=[gr.Textbox(label="Transcribed Text", lines=15), gr.JSON(label="Transcribed JSON")]
|
175 |
)
|
176 |
|