rohitp1 commited on
Commit
fc40086
·
1 Parent(s): e32df79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -28
app.py CHANGED
@@ -6,41 +6,47 @@
6
  import gradio as gr
7
  import os
8
  import transformers
9
- from transformers import pipeline
10
  import time
11
 
12
- auth_token = os.getenv("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")
 
 
13
 
14
- # p = pipeline('automatic-speech-recognition', model='rohitp1/kkkh_whisper_small_distillation_att_loss_libri360_epochs_100_batch_4_concat_dataset')
15
 
16
- # def transcribe(audio, state=""):
17
- # time.sleep(3)
18
- # text = p(audio)["text"]
19
- # state = text + " "
20
- # return state, state
21
 
 
22
 
 
 
 
 
 
23
 
24
- # gr.Interface(
25
- # fn=transcribe,
26
- # inputs=[
27
- # gr.inputs.Audio(source="microphone", type="filepath"),
28
- # 'state'
29
- # ],
30
- # outputs=[
31
- # "textbox",
32
- # "state"
33
- # ],
34
- # live=False,
35
- # api_key=auth_token).launch()
36
 
37
 
38
- demo = gr.load(
39
- "huggingface/rohitp1/kkkh_whisper_small_distillation_att_loss_libri360_epochs_100_batch_4_concat_dataset",
40
- title="Speech-to-text",
41
- inputs="mic",
42
- description="Let me try to guess what you're saying!",
43
- api_key="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"
44
- )
 
 
 
 
45
 
46
- demo.launch()
 
 
 
 
 
 
 
 
 
 
6
  import gradio as gr
7
  import os
8
  import transformers
9
+ from transformers import pipeline, WhisperFromConditionalGeneration
10
  import time
11
 
12
+ # def greet_from_secret(ignored_param):
13
+ # name = os.environ.get('TOKEN')
14
+ # return
15
 
 
16
 
17
+ auth_token = os.environ.get('TOKEN')
18
+ model = WhisperFromConditionalGeneration.from_pretrained("rohitp1/kkkh_whisper_small_distillation_att_loss_libri360_epochs_100_batch_4_concat_dataset",
19
+ use_auth_token=auth_token)
 
 
20
 
21
+ p = pipeline('automatic-speech-recognition', model=model)
22
 
23
+ def transcribe(audio, state=""):
24
+ time.sleep(3)
25
+ text = p(audio)["text"]
26
+ state = text + " "
27
+ return state, state
28
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
 
31
+ gr.Interface(
32
+ fn=transcribe,
33
+ inputs=[
34
+ gr.inputs.Audio(source="microphone", type="filepath"),
35
+ 'state'
36
+ ],
37
+ outputs=[
38
+ "textbox",
39
+ "state"
40
+ ],
41
+ live=False).launch()
42
 
43
+
44
+ # demo = gr.load(
45
+ # "huggingface/rohitp1/kkkh_whisper_small_distillation_att_loss_libri360_epochs_100_batch_4_concat_dataset",
46
+ # title="Speech-to-text",
47
+ # inputs="mic",
48
+ # description="Let me try to guess what you're saying!",
49
+ # api_key="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"
50
+ # )
51
+
52
+ # demo.launch()