sabya87 commited on
Commit
b22a6fb
·
1 Parent(s): 01db5c7

Update app.py

Browse files

Changing language to German. Changes in model, tokeniser and translate()

Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -14,15 +14,15 @@ asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base",
14
  # load text-to-speech checkpoint and speaker embeddings
15
  #processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
16
 
17
- model = VitsModel.from_pretrained("Matthijs/mms-tts-fra").to(device)
18
- tokenizer = VitsTokenizer.from_pretrained("Matthijs/mms-tts-fra")
19
 
20
  #embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
21
  #speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
22
 
23
 
24
  def translate(audio):
25
- outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "transcribe", "language": "fr"})
26
  return outputs["text"]
27
 
28
 
@@ -49,7 +49,7 @@ def speech_to_speech_translation(audio):
49
 
50
  title = "Cascaded STST"
51
  description = """
52
- Demo for cascaded speech-to-speech translation (STST), mapping from source speech in any language to target speech in English. Demo uses OpenAI's [Whisper Base](https://huggingface.co/openai/whisper-base) model for speech translation, and Microsoft's
53
  [SpeechT5 TTS](https://huggingface.co/microsoft/speecht5_tts) model for text-to-speech:
54
 
55
  ![Cascaded STST](https://huggingface.co/datasets/huggingface-course/audio-course-images/resolve/main/s2st_cascaded.png "Diagram of cascaded speech to speech translation")
 
14
  # load text-to-speech checkpoint and speaker embeddings
15
  #processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
16
 
17
+ model = VitsModel.from_pretrained("Matthijs/mms-tts-dae").to(device)
18
+ tokenizer = VitsTokenizer.from_pretrained("Matthijs/mms-tts-dae")
19
 
20
  #embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
21
  #speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
22
 
23
 
24
  def translate(audio):
25
+ outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "transcribe", "language": "de"})
26
  return outputs["text"]
27
 
28
 
 
49
 
50
  title = "Cascaded STST"
51
  description = """
52
+ Demo for cascaded speech-to-speech translation (STST), mapping from source speech in any language to target speech in German. Demo uses OpenAI's [Whisper Base](https://huggingface.co/openai/whisper-base) model for speech translation, and Microsoft's
53
  [SpeechT5 TTS](https://huggingface.co/microsoft/speecht5_tts) model for text-to-speech:
54
 
55
  ![Cascaded STST](https://huggingface.co/datasets/huggingface-course/audio-course-images/resolve/main/s2st_cascaded.png "Diagram of cascaded speech to speech translation")