Update voice_processing.py
Browse files- voice_processing.py +10 -5
voice_processing.py
CHANGED
@@ -205,11 +205,16 @@ async def tts(
|
|
205 |
info = f"Success. Time: tts: {edge_time:.2f}s, npy: {times[0]:.2f}s, f0: {times[1]:.2f}s, infer: {times[2]:.2f}s"
|
206 |
print(info)
|
207 |
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
info,
|
210 |
-
|
211 |
-
|
212 |
-
)
|
213 |
|
214 |
except Exception as e:
|
215 |
print(f"Error in TTS task: {str(e)}")
|
@@ -217,7 +222,7 @@ async def tts(
|
|
217 |
traceback.print_exc()
|
218 |
if os.path.exists(edge_output_filename):
|
219 |
os.remove(edge_output_filename)
|
220 |
-
return str(e), None
|
221 |
|
222 |
voice_mapping = {
|
223 |
"Mongolian Male": "mn-MN-BataaNeural",
|
|
|
205 |
info = f"Success. Time: tts: {edge_time:.2f}s, npy: {times[0]:.2f}s, f0: {times[1]:.2f}s, infer: {times[2]:.2f}s"
|
206 |
print(info)
|
207 |
|
208 |
+
# Convert audio to base64
|
209 |
+
with open(edge_output_filename, "rb") as audio_file:
|
210 |
+
audio_base64 = base64.b64encode(audio_file.read()).decode('utf-8')
|
211 |
+
|
212 |
+
audio_data_uri = f"data:audio/mp3;base64,{audio_base64}"
|
213 |
+
|
214 |
+
return [
|
215 |
info,
|
216 |
+
audio_data_uri
|
217 |
+
]
|
|
|
218 |
|
219 |
except Exception as e:
|
220 |
print(f"Error in TTS task: {str(e)}")
|
|
|
222 |
traceback.print_exc()
|
223 |
if os.path.exists(edge_output_filename):
|
224 |
os.remove(edge_output_filename)
|
225 |
+
return [str(e), None]
|
226 |
|
227 |
voice_mapping = {
|
228 |
"Mongolian Male": "mn-MN-BataaNeural",
|