import torch import soundfile as sf from .config import pipe_tts from io import BytesIO SAMPLING_RATE = 16000 class T2A: def __init__(self, input_text: str): self.output_model = pipe_tts(input_text) def get_audio(self): if self.inputs is not None: synth = self.output_model["audio"][0] print(f"synth : {synth}") with BytesIO() as buffer: sf.write(buffer, synth, SAMPLING_RATE, format='wav') output = buffer.getvalue() # bytes print(f"output : {output}, type : {type(output)}") return output else: raise Exception("Input text is None. Please provide text")