fffiloni commited on
Commit
93d7e30
1 Parent(s): f07ee57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -9,6 +9,7 @@ from gradio_client import Client
9
  eleven = Client("https://elevenlabs-tts.hf.space/")
10
 
11
  import wave
 
12
 
13
  openai_api_key = os.environ.get("OPENAI_API_KEY")
14
 
@@ -81,7 +82,15 @@ def generate_story(text, lang):
81
  output_wav = 'output.wav'
82
 
83
  join_wav_files(input_waves, output_wav)
84
- return story_result, 'output.wav'
 
 
 
 
 
 
 
 
85
 
86
  def app(text, lang):
87
  story = generate_story(text, lang)
 
9
  eleven = Client("https://elevenlabs-tts.hf.space/")
10
 
11
  import wave
12
+ from pydub import AudioSegment
13
 
14
  openai_api_key = os.environ.get("OPENAI_API_KEY")
15
 
 
82
  output_wav = 'output.wav'
83
 
84
  join_wav_files(input_waves, output_wav)
85
+
86
+ # Load the WAV file
87
+ wav_file = AudioSegment.from_file("output.wav", format="wav")
88
+
89
+ # Export it as an MP3 file
90
+ mp3_file = "output.mp3"
91
+ wav_file.export(mp3_file, format="mp3")
92
+
93
+ return story_result, 'output.mp3'
94
 
95
  def app(text, lang):
96
  story = generate_story(text, lang)