Spaces:
Sleeping
Sleeping
Commit
·
fd5d828
1
Parent(s):
a5930e4
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,8 +17,8 @@ def transcribe(inputs, task):
|
|
| 17 |
if inputs is None:
|
| 18 |
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
|
| 19 |
|
| 20 |
-
text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task":
|
| 21 |
-
return
|
| 22 |
|
| 23 |
def transcribelocal(microphone, file_upload):
|
| 24 |
# Check which input is not None
|
|
@@ -27,15 +27,14 @@ def transcribelocal(microphone, file_upload):
|
|
| 27 |
else:
|
| 28 |
audio = file_upload
|
| 29 |
|
| 30 |
-
|
| 31 |
-
return text
|
| 32 |
|
| 33 |
# Create a Gradio interface with two modes: realtime and file upload
|
| 34 |
iface = gr.Interface(
|
| 35 |
fn=transcribelocal,
|
| 36 |
inputs=[
|
| 37 |
-
gr.inputs.Audio(source="microphone", type="
|
| 38 |
-
gr.inputs.Audio(source="upload", type="
|
| 39 |
],
|
| 40 |
outputs=[
|
| 41 |
gr.outputs.Textbox(label="Transcription"),
|
|
|
|
| 17 |
if inputs is None:
|
| 18 |
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
|
| 19 |
|
| 20 |
+
text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
|
| 21 |
+
return text
|
| 22 |
|
| 23 |
def transcribelocal(microphone, file_upload):
|
| 24 |
# Check which input is not None
|
|
|
|
| 27 |
else:
|
| 28 |
audio = file_upload
|
| 29 |
|
| 30 |
+
return transcribe(audio, "transcribe")
|
|
|
|
| 31 |
|
| 32 |
# Create a Gradio interface with two modes: realtime and file upload
|
| 33 |
iface = gr.Interface(
|
| 34 |
fn=transcribelocal,
|
| 35 |
inputs=[
|
| 36 |
+
gr.inputs.Audio(source="microphone", type="filepath", label="Realtime Mode"),
|
| 37 |
+
gr.inputs.Audio(source="upload", type="filepath", label="File Upload Mode")
|
| 38 |
],
|
| 39 |
outputs=[
|
| 40 |
gr.outputs.Textbox(label="Transcription"),
|