Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,7 @@ model.enable_cpu_offload()
|
|
| 18 |
|
| 19 |
import numpy as np
|
| 20 |
from scipy.io import wavfile
|
|
|
|
| 21 |
|
| 22 |
def infer(text_prompt):
|
| 23 |
text_prompt = text_prompt
|
|
@@ -29,8 +30,14 @@ def infer(text_prompt):
|
|
| 29 |
# Assuming audio_out contains audio data and the sampling rate
|
| 30 |
sampling_rate = model.generation_config.sample_rate
|
| 31 |
wavfile.write("output.wav", sampling_rate, audio_out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
return
|
| 34 |
|
| 35 |
with gr.Blocks() as demo:
|
| 36 |
with gr.Column():
|
|
|
|
| 18 |
|
| 19 |
import numpy as np
|
| 20 |
from scipy.io import wavfile
|
| 21 |
+
from pydub import AudioSegment
|
| 22 |
|
| 23 |
def infer(text_prompt):
|
| 24 |
text_prompt = text_prompt
|
|
|
|
| 30 |
# Assuming audio_out contains audio data and the sampling rate
|
| 31 |
sampling_rate = model.generation_config.sample_rate
|
| 32 |
wavfile.write("output.wav", sampling_rate, audio_out)
|
| 33 |
+
|
| 34 |
+
wav_path = "output.wav"
|
| 35 |
+
mp3_path = "output.mp3"
|
| 36 |
+
|
| 37 |
+
audio = AudioSegment.from_wav(wav_path)
|
| 38 |
+
audio.export(mp3_path, format="mp3")
|
| 39 |
|
| 40 |
+
return mp3_path
|
| 41 |
|
| 42 |
with gr.Blocks() as demo:
|
| 43 |
with gr.Column():
|