Spaces:
Runtime error
Runtime error
changed model and tokeniser to general MMS TTS; updated synthesise()
Browse files
app.py
CHANGED
@@ -12,8 +12,8 @@ device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
|
12 |
asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=device)
|
13 |
|
14 |
# load text-to-speech checkpoint and speaker embeddings
|
15 |
-
model = VitsModel.from_pretrained("facebook/mms-tts
|
16 |
-
tokenizer = VitsTokenizer.from_pretrained("facebook/mms-tts
|
17 |
|
18 |
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
19 |
speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
|
@@ -26,11 +26,9 @@ def translate(audio):
|
|
26 |
|
27 |
def synthesise(text):
|
28 |
inputs = tokenizer(text, return_tensors="pt")
|
29 |
-
input_ids = inputs["input_ids"]
|
30 |
with torch.no_grad():
|
31 |
-
|
32 |
-
|
33 |
-
return speech.cpu()
|
34 |
|
35 |
|
36 |
def speech_to_speech_translation(audio):
|
|
|
12 |
asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=device)
|
13 |
|
14 |
# load text-to-speech checkpoint and speaker embeddings
|
15 |
+
model = VitsModel.from_pretrained("facebook/mms-tts")
|
16 |
+
tokenizer = VitsTokenizer.from_pretrained("facebook/mms-tts")
|
17 |
|
18 |
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
19 |
speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
|
|
|
26 |
|
27 |
def synthesise(text):
|
28 |
inputs = tokenizer(text, return_tensors="pt")
|
|
|
29 |
with torch.no_grad():
|
30 |
+
output = model(**inputs).waveform
|
31 |
+
return output.cpu()
|
|
|
32 |
|
33 |
|
34 |
def speech_to_speech_translation(audio):
|