Antoine101 commited on
Commit
c9d7c13
·
verified ·
1 Parent(s): cd35236

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -14,10 +14,10 @@ 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 = SpeechT5ForTextToSpeech.from_pretrained("microsoft/speecht5_tts").to(device)
18
- vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
19
- #model = VitsModel.from_pretrained("facebook/mms-tts-fra")
20
- #tokenizer = VitsTokenizer.from_pretrained("facebook/mms-tts-fra")
21
 
22
  embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
23
  speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
@@ -29,12 +29,12 @@ def translate(audio):
29
 
30
 
31
  def synthesise(text):
32
- inputs = processor(text=text, return_tensors="pt")
33
- speech = model.generate_speech(inputs["input_ids"].to(device), speaker_embeddings.to(device), vocoder=vocoder)
34
- output = speech
35
- #inputs = tokenizer(text, return_tensors="pt")
36
- #speech = model(inputs["input_ids"])
37
- #output = speech["waveform"].detach()
38
  print(output)
39
  print(output.size())
40
  print(torch.min(output))
 
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
+ model = VitsModel.from_pretrained("facebook/mms-tts-fra")
20
+ tokenizer = VitsTokenizer.from_pretrained("facebook/mms-tts-fra")
21
 
22
  embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
23
  speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
 
29
 
30
 
31
  def synthesise(text):
32
+ #inputs = processor(text=text, return_tensors="pt")
33
+ #speech = model.generate_speech(inputs["input_ids"].to(device), speaker_embeddings.to(device), vocoder=vocoder)
34
+ #output = speech
35
+ inputs = tokenizer(text, return_tensors="pt")
36
+ speech = model(inputs["input_ids"])
37
+ output = torch.squeeze(speech["waveform"].detach())
38
  print(output)
39
  print(output.size())
40
  print(torch.min(output))