CineAI commited on
Commit
0fb503b
1 Parent(s): 8d06043

Update audio_processing/T2A.py

Browse files
Files changed (1) hide show
  1. 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 model_mms_tts_eng, tokenizer_mms_tts_eng
 
4
 
5
  SAMPLING_RATE = 16000
6
 
7
  class T2A:
8
  def __init__(self, input_text: str):
9
- self.inputs = tokenizer_mms_tts_eng(input_text, return_tensors="pt")
10
 
11
  def get_audio(self):
12
  if self.inputs is not None:
13
- with torch.no_grad():
14
- output_model = model_mms_tts_eng(**self.inputs)
15
 
16
- print(f"output_model : {output_model}")
17
-
18
- audio = output_model["audio"][0]
19
-
20
- print(f"audio : {audio}")
21
 
22
  with BytesIO() as buffer:
23
- sf.write(buffer, audio, SAMPLING_RATE, format='wav')
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: