Spaces:
Runtime error
Runtime error
Update app.py
Browse filesreverted to dutch
app.py
CHANGED
@@ -6,15 +6,15 @@ from datasets import load_dataset
|
|
6 |
from transformers import SpeechT5ForTextToSpeech, SpeechT5HifiGan, SpeechT5Processor, pipeline
|
7 |
|
8 |
|
9 |
-
|
10 |
-
device = "cpu"
|
11 |
|
12 |
# load speech translation checkpoint
|
13 |
asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=device)
|
14 |
|
15 |
# load text-to-speech checkpoint and speaker embeddings
|
16 |
#processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
|
17 |
-
processor = SpeechT5Processor.from_pretrained("
|
18 |
model = SpeechT5ForTextToSpeech.from_pretrained("aoliveira/speecht5_finetuned_voxpopuli_sk").to(device)
|
19 |
#model = SpeechT5ForTextToSpeech.from_pretrained("sanchit-gandhi/speecht5_tts_vox_nl").to(device)
|
20 |
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
|
@@ -24,7 +24,7 @@ speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze
|
|
24 |
|
25 |
|
26 |
def translate(audio):
|
27 |
-
outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "transcribe", "language": "
|
28 |
return outputs["text"]
|
29 |
|
30 |
|
@@ -43,8 +43,8 @@ def speech_to_speech_translation(audio):
|
|
43 |
|
44 |
title = "Cascaded STST"
|
45 |
description = """
|
46 |
-
Demo for cascaded speech-to-speech translation (STST), mapping from source speech in any language to target speech in
|
47 |
-
SpeechT5 TTS model fine tuned for the
|
48 |
|
49 |
![Cascaded STST](https://huggingface.co/datasets/huggingface-course/audio-course-images/resolve/main/s2st_cascaded.png "Diagram of cascaded speech to speech translation")
|
50 |
"""
|
|
|
6 |
from transformers import SpeechT5ForTextToSpeech, SpeechT5HifiGan, SpeechT5Processor, pipeline
|
7 |
|
8 |
|
9 |
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
10 |
+
#device = "cpu"
|
11 |
|
12 |
# load speech translation checkpoint
|
13 |
asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=device)
|
14 |
|
15 |
# load text-to-speech checkpoint and speaker embeddings
|
16 |
#processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
|
17 |
+
processor = SpeechT5Processor.from_pretrained("sanchit-gandhi/speecht5_tts_vox_nl")
|
18 |
model = SpeechT5ForTextToSpeech.from_pretrained("aoliveira/speecht5_finetuned_voxpopuli_sk").to(device)
|
19 |
#model = SpeechT5ForTextToSpeech.from_pretrained("sanchit-gandhi/speecht5_tts_vox_nl").to(device)
|
20 |
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
|
|
|
24 |
|
25 |
|
26 |
def translate(audio):
|
27 |
+
outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "transcribe", "language": "nl"})
|
28 |
return outputs["text"]
|
29 |
|
30 |
|
|
|
43 |
|
44 |
title = "Cascaded STST"
|
45 |
description = """
|
46 |
+
Demo for cascaded speech-to-speech translation (STST), mapping from source speech in any language to target speech in Dutch. Demo uses OpenAI's [Whisper Base](https://huggingface.co/openai/whisper-base) model for speech translation, and Microsoft's
|
47 |
+
SpeechT5 TTS model fine tuned for the Dutch language for text-to-speech:
|
48 |
|
49 |
![Cascaded STST](https://huggingface.co/datasets/huggingface-course/audio-course-images/resolve/main/s2st_cascaded.png "Diagram of cascaded speech to speech translation")
|
50 |
"""
|