Spaces:
Build error
Build error
Update audio_pipe.py
Browse files- audio_pipe.py +10 -1
audio_pipe.py
CHANGED
@@ -2,6 +2,8 @@ import json
|
|
2 |
import os
|
3 |
from pathlib import Path
|
4 |
from typing import List, Tuple
|
|
|
|
|
5 |
|
6 |
import numpy as np
|
7 |
import torch
|
@@ -148,5 +150,12 @@ class SpeechToSpeechPipeline():
|
|
148 |
wav, sr = TTSHubInterface.get_prediction(
|
149 |
self.tts_task, self.tts_model, self.tts_generator, tts_sample
|
150 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
-
return wav, sr, [text]
|
|
|
|
2 |
import os
|
3 |
from pathlib import Path
|
4 |
from typing import List, Tuple
|
5 |
+
import tempfile
|
6 |
+
import soundfile as sf
|
7 |
|
8 |
import numpy as np
|
9 |
import torch
|
|
|
150 |
wav, sr = TTSHubInterface.get_prediction(
|
151 |
self.tts_task, self.tts_model, self.tts_generator, tts_sample
|
152 |
)
|
153 |
+
temp_name = ""
|
154 |
+
with tempfile.NamedTemporaryFile(suffix=".wav") as tmp_output_file:
|
155 |
+
sf.write(tmp_output_file, wav.detach().cpu().numpy(), sr)
|
156 |
+
tmp_output_file.seek(0)
|
157 |
+
temp_name = tmp_output_file.name
|
158 |
+
print(temp_name)
|
159 |
|
160 |
+
# return wav, sr, [text]
|
161 |
+
return temp_name
|