Spaces:
Running
Running
Jan van Doorn
commited on
commit
Browse files
app.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
#%%
|
2 |
-
from huggingface_hub import login
|
3 |
from transformers import pipeline
|
4 |
from datasets import load_dataset
|
5 |
import gradio as gr
|
@@ -12,18 +10,15 @@ num_examples = 3
|
|
12 |
examples_atco2 = [ [{'sampling_rate': atco2[i]['audio']['sampling_rate'], 'raw': atco2[i]['audio']['array']}, False, 'large-v3'] for i in range(num_examples)]
|
13 |
#examples_atcosim = [ [{'sampling_rate': atcosim[i]['audio']['sampling_rate'], 'raw': atcosim[i]['audio']['array']}, False, 'large-v3'] for i in range(num_examples)]
|
14 |
examples = examples_atco2 #+ examples_atcosim
|
15 |
-
# examples = [atco2[0]['audio']['array'], atcosim[0]['audio']['array'], atco2[1]['audio']['array'], atcosim[1]['audio']['array'], atco2[2]['audio']['array'], atcosim[2]['audio']['array']]
|
16 |
-
# examples_labels = ['Example ' + str(i+1) for i in range(len(examples))]
|
17 |
|
18 |
whisper = pipeline(model='jlvdoorn/whisper-large-v3-atco2-asr-atcosim')
|
19 |
-
|
20 |
def transcribe(audio, model_version):
|
21 |
if audio is not None:
|
22 |
return whisper(audio)['text']
|
23 |
else:
|
24 |
return 'There was no audio to transcribe...'
|
25 |
|
26 |
-
#%%
|
27 |
file_iface = gr.Interface(
|
28 |
fn = transcribe,
|
29 |
inputs = [gr.Audio(source='upload', interactive=True),
|
@@ -48,6 +43,6 @@ mic_iface = gr.Interface(
|
|
48 |
title = 'Whisper ATC - Large v3',
|
49 |
description = 'Transcribe ATC speech',
|
50 |
)
|
51 |
-
|
52 |
demo = gr.TabbedInterface([file_iface, mic_iface], ["File", "Microphone"])
|
53 |
-
demo.launch()
|
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
from datasets import load_dataset
|
3 |
import gradio as gr
|
|
|
10 |
examples_atco2 = [ [{'sampling_rate': atco2[i]['audio']['sampling_rate'], 'raw': atco2[i]['audio']['array']}, False, 'large-v3'] for i in range(num_examples)]
|
11 |
#examples_atcosim = [ [{'sampling_rate': atcosim[i]['audio']['sampling_rate'], 'raw': atcosim[i]['audio']['array']}, False, 'large-v3'] for i in range(num_examples)]
|
12 |
examples = examples_atco2 #+ examples_atcosim
|
|
|
|
|
13 |
|
14 |
whisper = pipeline(model='jlvdoorn/whisper-large-v3-atco2-asr-atcosim')
|
15 |
+
|
16 |
def transcribe(audio, model_version):
|
17 |
if audio is not None:
|
18 |
return whisper(audio)['text']
|
19 |
else:
|
20 |
return 'There was no audio to transcribe...'
|
21 |
|
|
|
22 |
file_iface = gr.Interface(
|
23 |
fn = transcribe,
|
24 |
inputs = [gr.Audio(source='upload', interactive=True),
|
|
|
43 |
title = 'Whisper ATC - Large v3',
|
44 |
description = 'Transcribe ATC speech',
|
45 |
)
|
46 |
+
|
47 |
demo = gr.TabbedInterface([file_iface, mic_iface], ["File", "Microphone"])
|
48 |
+
demo.launch(server_name='0.0.0.0')
|