Marco-Cheung
commited on
Commit
•
5099504
1
Parent(s):
ce5168c
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import torch
|
4 |
-
from transformers import AutoProcessor, pipeline, BarkModel
|
5 |
|
6 |
ASR_MODEL_NAME = "bofenghuang/whisper-large-v2-cv11-german"
|
7 |
TTS_MODEL_NAME = "suno/bark-small"
|
@@ -10,11 +10,20 @@ voices = {
|
|
10 |
"male" : "v2/de_speaker_0",
|
11 |
"female" : "v2/de_speaker_3"
|
12 |
}
|
|
|
13 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
14 |
|
15 |
# load speech translation checkpoint
|
16 |
asr_pipe = pipeline("automatic-speech-recognition", model=ASR_MODEL_NAME, chunk_length_s=10,device=device)
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# load text-to-speech checkpoint
|
19 |
processor = AutoProcessor.from_pretrained("suno/bark-small")
|
20 |
model = BarkModel.from_pretrained("suno/bark-small").to(device)
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import torch
|
4 |
+
from transformers import AutoProcessor, pipeline, BarkModel, GenerationConfig
|
5 |
|
6 |
ASR_MODEL_NAME = "bofenghuang/whisper-large-v2-cv11-german"
|
7 |
TTS_MODEL_NAME = "suno/bark-small"
|
|
|
10 |
"male" : "v2/de_speaker_0",
|
11 |
"female" : "v2/de_speaker_3"
|
12 |
}
|
13 |
+
|
14 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
15 |
|
16 |
# load speech translation checkpoint
|
17 |
asr_pipe = pipeline("automatic-speech-recognition", model=ASR_MODEL_NAME, chunk_length_s=10,device=device)
|
18 |
|
19 |
+
# update the generation config
|
20 |
+
MULTILINGUAL = True # set True for multilingual models, False for English-only
|
21 |
+
generation_config = GenerationConfig.from_pretrained("openai/whisper-large-v2")
|
22 |
+
#else:
|
23 |
+
#generation_config = GenerationConfig.from_pretrained("openai/whisper-medium.en")
|
24 |
+
generation_config.push_to_hub(ASR_MODEL_NAME)
|
25 |
+
|
26 |
+
|
27 |
# load text-to-speech checkpoint
|
28 |
processor = AutoProcessor.from_pretrained("suno/bark-small")
|
29 |
model = BarkModel.from_pretrained("suno/bark-small").to(device)
|