hbui commited on
Commit
95e95ed
·
verified ·
1 Parent(s): 4d6559b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
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
- # Save the audio data to a temporary file
22
- with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as tmpfile:
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()