Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,10 @@ import numpy as np
|
|
3 |
import torch
|
4 |
from datasets import load_dataset
|
5 |
|
6 |
-
from transformers import SpeechT5ForTextToSpeech, SpeechT5HifiGan, SpeechT5Processor, pipeline
|
7 |
-
|
|
|
|
|
8 |
|
9 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
10 |
|
@@ -12,10 +14,12 @@ device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
|
12 |
asr_pipe = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-100h", device=device)
|
13 |
|
14 |
# load text-to-speech checkpoint and speaker embeddings
|
15 |
-
processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
|
|
|
|
|
16 |
|
17 |
-
model =
|
18 |
-
|
19 |
|
20 |
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
21 |
speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
|
@@ -28,7 +32,8 @@ def translate(audio):
|
|
28 |
|
29 |
def synthesise(text):
|
30 |
inputs = processor(text=text, return_tensors="pt")
|
31 |
-
speech = model.generate_speech(inputs["input_ids"].to(device), speaker_embeddings.to(device), vocoder=vocoder)
|
|
|
32 |
return speech.cpu()
|
33 |
|
34 |
|
|
|
3 |
import torch
|
4 |
from datasets import load_dataset
|
5 |
|
6 |
+
#from transformers import SpeechT5ForTextToSpeech, SpeechT5HifiGan, SpeechT5Processor, pipeline
|
7 |
+
from transformers import pipeline
|
8 |
+
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
|
9 |
+
from transformers import BarkModel, BarkProcessor
|
10 |
|
11 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
12 |
|
|
|
14 |
asr_pipe = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-100h", device=device)
|
15 |
|
16 |
# load text-to-speech checkpoint and speaker embeddings
|
17 |
+
#processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
|
18 |
+
#model = SpeechT5ForTextToSpeech.from_pretrained("microsoft/speecht5_tts").to(device)
|
19 |
+
#vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
|
20 |
|
21 |
+
model = BarkModel.from_pretrained("suno/bark-small")
|
22 |
+
processor = BarkProcessor.from_pretrained("suno/bark-small")
|
23 |
|
24 |
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
25 |
speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
|
|
|
32 |
|
33 |
def synthesise(text):
|
34 |
inputs = processor(text=text, return_tensors="pt")
|
35 |
+
#speech = model.generate_speech(inputs["input_ids"].to(device), speaker_embeddings.to(device), vocoder=vocoder)
|
36 |
+
speech = model.generate_speech(inputs["input_ids"].to(device), speaker_embeddings.to(device))
|
37 |
return speech.cpu()
|
38 |
|
39 |
|