Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
# from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
3 |
from datasets import load_dataset
|
4 |
-
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
|
|
|
|
|
5 |
|
6 |
import torch
|
7 |
# import librosa
|
@@ -11,17 +13,20 @@ import torch
|
|
11 |
# processor = WhisperProcessor.from_pretrained(model_name)
|
12 |
# model = WhisperForConditionalGeneration.from_pretrained(model_name)
|
13 |
|
14 |
-
|
15 |
|
16 |
-
models = AutoModelForSpeechSeq2Seq.from_pretrained(
|
17 |
-
|
18 |
-
)
|
|
|
|
|
|
|
19 |
|
20 |
-
model = pipeline("automatic-speech-recognition", model=models, chunk_length_s=30, device=0)
|
21 |
|
22 |
# 加载数据集 bigcode/the-stack
|
23 |
|
24 |
-
|
25 |
|
26 |
def transcribe(audio_path):
|
27 |
# 加载音频文件并转换为信号
|
|
|
1 |
import gradio as gr
|
2 |
# from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
3 |
from datasets import load_dataset
|
4 |
+
# from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline,WhisperProcessor
|
5 |
+
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
6 |
+
|
7 |
|
8 |
import torch
|
9 |
# import librosa
|
|
|
13 |
# processor = WhisperProcessor.from_pretrained(model_name)
|
14 |
# model = WhisperForConditionalGeneration.from_pretrained(model_name)
|
15 |
|
16 |
+
model_name = "openai/whisper-large-v3-turbo"
|
17 |
|
18 |
+
# models = AutoModelForSpeechSeq2Seq.from_pretrained(
|
19 |
+
# model_id, low_cpu_mem_usage=True
|
20 |
+
# )
|
21 |
+
|
22 |
+
processor = WhisperProcessor.from_pretrained(model_name)
|
23 |
+
model = WhisperForConditionalGeneration.from_pretrained(model_name)
|
24 |
|
25 |
+
# model = pipeline("automatic-speech-recognition", model=models, chunk_length_s=30, device=0)
|
26 |
|
27 |
# 加载数据集 bigcode/the-stack
|
28 |
|
29 |
+
ds = load_dataset("CoIR-Retrieval/CodeSearchNet-php-queries-corpus")
|
30 |
|
31 |
def transcribe(audio_path):
|
32 |
# 加载音频文件并转换为信号
|