Spaces:
Runtime error
Runtime error
Commit
·
df721da
1
Parent(s):
fe7fc8b
Unit 7 - Working copy - French
Browse files
app.py
CHANGED
@@ -10,17 +10,16 @@ device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
|
10 |
asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=device)
|
11 |
|
12 |
# load text-to-speech checkpoint and speaker embeddings
|
13 |
-
processor = SpeechT5Processor.from_pretrained("
|
14 |
|
15 |
-
model = SpeechT5ForTextToSpeech.from_pretrained("
|
16 |
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
|
17 |
|
18 |
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation", streaming = True)
|
19 |
speaker_embeddings = torch.tensor(next(iter(embeddings_dataset))["xvector"]).unsqueeze(0)
|
20 |
|
21 |
def translate(audio):
|
22 |
-
outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "transcribe", "language": "
|
23 |
-
print(outputs["text"])
|
24 |
return outputs["text"]
|
25 |
|
26 |
|
|
|
10 |
asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=device)
|
11 |
|
12 |
# load text-to-speech checkpoint and speaker embeddings
|
13 |
+
processor = SpeechT5Processor.from_pretrained("Sandiago21/speecht5_finetuned_facebook_voxpopuli_french")
|
14 |
|
15 |
+
model = SpeechT5ForTextToSpeech.from_pretrained("Sandiago21/speecht5_finetuned_facebook_voxpopuli_french").to(device)
|
16 |
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
|
17 |
|
18 |
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation", streaming = True)
|
19 |
speaker_embeddings = torch.tensor(next(iter(embeddings_dataset))["xvector"]).unsqueeze(0)
|
20 |
|
21 |
def translate(audio):
|
22 |
+
outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "transcribe", "language": "fr"})
|
|
|
23 |
return outputs["text"]
|
24 |
|
25 |
|