Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,14 +27,19 @@ pipe = pipeline(
|
|
27 |
torch_dtype=torch_dtype,
|
28 |
device=device,
|
29 |
)
|
|
|
30 |
def transcribe_audio(audio_file):
|
|
|
|
|
|
|
|
|
31 |
# Use the pipeline to transcribe audio
|
32 |
result = pipe(audio_file, generate_kwargs={"language": "english"})
|
33 |
transcribed_text = result["text"]
|
34 |
return transcribed_text
|
35 |
|
36 |
# Create a Gradio interface
|
37 |
-
audio_input = gr.Audio()
|
38 |
output_text = gr.Textbox(label="Transcribed Text")
|
39 |
|
40 |
# Instantiate the Gradio interface
|
@@ -48,4 +53,4 @@ app = gr.Interface(
|
|
48 |
)
|
49 |
|
50 |
# Launch the Gradio interface
|
51 |
-
app.launch(debug=True,inline=False)
|
|
|
27 |
torch_dtype=torch_dtype,
|
28 |
device=device,
|
29 |
)
|
30 |
+
|
31 |
def transcribe_audio(audio_file):
|
32 |
+
# Check if audio file is None
|
33 |
+
if audio_file is None:
|
34 |
+
raise ValueError("Input audio file is None.")
|
35 |
+
|
36 |
# Use the pipeline to transcribe audio
|
37 |
result = pipe(audio_file, generate_kwargs={"language": "english"})
|
38 |
transcribed_text = result["text"]
|
39 |
return transcribed_text
|
40 |
|
41 |
# Create a Gradio interface
|
42 |
+
audio_input = gr.Audio(label="Upload Audio", type="file")
|
43 |
output_text = gr.Textbox(label="Transcribed Text")
|
44 |
|
45 |
# Instantiate the Gradio interface
|
|
|
53 |
)
|
54 |
|
55 |
# Launch the Gradio interface
|
56 |
+
app.launch(debug=True, inline=False)
|