Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -40,9 +40,20 @@ decoding_cfg = model.cfg.decoding
|
|
40 |
decoding_cfg.beam.beam_size = 1
|
41 |
model.change_decoding_strategy(decoding_cfg)
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
amp_dtype = torch.float16
|
46 |
|
47 |
|
48 |
def convert_audio(audio_filepath, tmpdir, utt_id):
|
@@ -98,11 +109,11 @@ start = {"role": "system", "content": "You are a helpful digital assistant. Plea
|
|
98 |
|
99 |
|
100 |
def generate_response(user_input):
|
101 |
-
messages = [start, {"role": "user", "content": user_input
|
102 |
inputs = proc_tokenizer.apply_chat_template(
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
)
|
107 |
|
108 |
|
|
|
40 |
decoding_cfg.beam.beam_size = 1
|
41 |
model.change_decoding_strategy(decoding_cfg)
|
42 |
|
43 |
+
'''
|
44 |
+
vits_model = VitsModel.from_pretrained("facebook/mms-tts-eng")
|
45 |
+
vits_tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-eng")
|
46 |
+
set_seed(555)
|
47 |
+
'''
|
48 |
+
|
49 |
+
def text_to_speech(text_response):
|
50 |
+
inputs = vits_tokenizer(text=text_response, return_tensors="pt")
|
51 |
+
with torch.no_grad():
|
52 |
+
outputs = vits_model(**inputs)
|
53 |
+
waveform = outputs.waveform[0]
|
54 |
+
sf.write('output.wav', waveform.numpy(), vits_model.config.sampling_rate)
|
55 |
|
56 |
+
return 'output.wav'
|
|
|
57 |
|
58 |
|
59 |
def convert_audio(audio_filepath, tmpdir, utt_id):
|
|
|
109 |
|
110 |
|
111 |
def generate_response(user_input):
|
112 |
+
messages = [start, {"role": "user", "content": user_input}]
|
113 |
inputs = proc_tokenizer.apply_chat_template(
|
114 |
+
messages,
|
115 |
+
add_generation_prompt=True,
|
116 |
+
return_tensors="pt",
|
117 |
)
|
118 |
|
119 |
|