ihanif commited on
Commit
132bef4
1 Parent(s): c03d869

Use lt fine-tuned model for TTS

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -11,10 +11,13 @@ device = "cuda:0" if torch.cuda.is_available() else "cpu"
11
  # load speech translation checkpoint
12
  asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=device)
13
 
14
- # load text-to-speech checkpoint and speaker embeddings
15
- processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
 
16
 
17
- model = SpeechT5ForTextToSpeech.from_pretrained("microsoft/speecht5_tts").to(device)
 
 
18
  vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
19
 
20
  embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
@@ -22,7 +25,7 @@ speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze
22
 
23
 
24
  def translate(audio):
25
- outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "translate"})
26
  return outputs["text"]
27
 
28
 
 
11
  # load speech translation checkpoint
12
  asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=device)
13
 
14
+ # load text-to-speech checkpoint and speaker embeddings
15
+ #processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
16
+ processor = SpeechT5Processor.from_pretrained("ihanif/speecht5_finetuned_voxpopuli_lt")
17
 
18
+ #model = SpeechT5ForTextToSpeech.from_pretrained("microsoft/speecht5_tts").to(device)
19
+ #vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
20
+ model = SpeechT5ForTextToSpeech.from_pretrained("ihanif/speecht5_finetuned_voxpopuli_lt").to(device)
21
  vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
22
 
23
  embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
 
25
 
26
 
27
  def translate(audio):
28
+ outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "translate", "language": "lt"})
29
  return outputs["text"]
30
 
31