Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
3 |
|
4 |
-
processor = WhisperProcessor.from_pretrained("
|
5 |
-
model = WhisperForConditionalGeneration.from_pretrained("
|
6 |
|
7 |
def transcrire_audio(audio, prompt):
|
8 |
input_features = processor(audio, return_tensors="pt").input_features
|
9 |
|
10 |
output_without_prompt = model.generate(input_features)
|
11 |
-
transcription_sans_prompt = processor.
|
12 |
|
13 |
prompt_ids = processor.get_prompt_ids(prompt)
|
14 |
output_with_prompt = model.generate(input_features, prompt_ids=prompt_ids)
|
15 |
-
transcription_avec_prompt = processor.
|
16 |
|
17 |
return {
|
18 |
"Transcription sans prompt": transcription_sans_prompt,
|
@@ -27,4 +27,3 @@ iface = gr.Interface(
|
|
27 |
)
|
28 |
|
29 |
iface.launch()
|
30 |
-
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline, WhisperProcessor, WhisperForConditionalGeneration
|
3 |
|
4 |
+
processor = WhisperProcessor.from_pretrained("facebook/whisper-large")
|
5 |
+
model = WhisperForConditionalGeneration.from_pretrained("facebook/whisper-large")
|
6 |
|
7 |
def transcrire_audio(audio, prompt):
|
8 |
input_features = processor(audio, return_tensors="pt").input_features
|
9 |
|
10 |
output_without_prompt = model.generate(input_features)
|
11 |
+
transcription_sans_prompt = processor.batch_decode(output_without_prompt, skip_special_tokens=True)[0]
|
12 |
|
13 |
prompt_ids = processor.get_prompt_ids(prompt)
|
14 |
output_with_prompt = model.generate(input_features, prompt_ids=prompt_ids)
|
15 |
+
transcription_avec_prompt = processor.batch_decode(output_with_prompt, skip_special_tokens=True)[0]
|
16 |
|
17 |
return {
|
18 |
"Transcription sans prompt": transcription_sans_prompt,
|
|
|
27 |
)
|
28 |
|
29 |
iface.launch()
|
|