Update audio_processing/T2A.py
Browse files- audio_processing/T2A.py +8 -11
audio_processing/T2A.py
CHANGED
@@ -1,29 +1,26 @@
|
|
1 |
import torch
|
2 |
import soundfile as sf
|
3 |
-
from .config import
|
|
|
4 |
|
5 |
SAMPLING_RATE = 16000
|
6 |
|
7 |
class T2A:
|
8 |
def __init__(self, input_text: str):
|
9 |
-
self.
|
10 |
|
11 |
def get_audio(self):
|
12 |
if self.inputs is not None:
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
print(f"
|
17 |
-
|
18 |
-
audio = output_model["audio"][0]
|
19 |
-
|
20 |
-
print(f"audio : {audio}")
|
21 |
|
22 |
with BytesIO() as buffer:
|
23 |
-
sf.write(buffer,
|
24 |
output = buffer.getvalue() # bytes
|
25 |
|
26 |
-
print(f"output : {output}")
|
27 |
|
28 |
return output
|
29 |
else:
|
|
|
1 |
import torch
|
2 |
import soundfile as sf
|
3 |
+
from .config import pipe_tts
|
4 |
+
from io import BytesIO
|
5 |
|
6 |
SAMPLING_RATE = 16000
|
7 |
|
8 |
class T2A:
|
9 |
def __init__(self, input_text: str):
|
10 |
+
self.output_model = pipe_tts(input_text)
|
11 |
|
12 |
def get_audio(self):
|
13 |
if self.inputs is not None:
|
14 |
+
|
15 |
+
synth = self.output_model["audio"][0]
|
16 |
|
17 |
+
print(f"synth : {synth}")
|
|
|
|
|
|
|
|
|
18 |
|
19 |
with BytesIO() as buffer:
|
20 |
+
sf.write(buffer, synth, SAMPLING_RATE, format='wav')
|
21 |
output = buffer.getvalue() # bytes
|
22 |
|
23 |
+
print(f"output : {output}, type : {type(output)}")
|
24 |
|
25 |
return output
|
26 |
else:
|