Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,17 +18,14 @@ def launch(input_text):
|
|
18 |
out = narrator(input_text)
|
19 |
audio_data, samplerate = np.array(out["audio"][0]), 22050 # Example: 22050 Hz as common sampling rate
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
-
sf.write(tmpfile.name, audio_data, samplerate)
|
24 |
-
# Return the path of the temporary audio file
|
25 |
-
return tmpfile.name
|
26 |
except Exception as e:
|
27 |
print(f"An error occurred: {e}")
|
28 |
-
return None
|
29 |
|
30 |
-
# Create the Gradio interface
|
31 |
-
iface = gr.Interface(fn=launch, inputs="text", outputs=gr.Audio())
|
32 |
|
33 |
# Launch the Gradio app
|
34 |
-
iface.launch()
|
|
|
18 |
out = narrator(input_text)
|
19 |
audio_data, samplerate = np.array(out["audio"][0]), 22050 # Example: 22050 Hz as common sampling rate
|
20 |
|
21 |
+
# Directly return the audio data and sampling rate.
|
22 |
+
return audio_data, samplerate
|
|
|
|
|
|
|
23 |
except Exception as e:
|
24 |
print(f"An error occurred: {e}")
|
25 |
+
return None, None
|
26 |
|
27 |
+
# Create the Gradio interface with the correct audio output handling.
|
28 |
+
iface = gr.Interface(fn=launch, inputs="text", outputs=gr.Audio(type="numpy", label="Your Audio"))
|
29 |
|
30 |
# Launch the Gradio app
|
31 |
+
iface.launch()
|