Anustup Mukherjee commited on
Commit
147feb7
·
1 Parent(s): 6a0045e
Files changed (2) hide show
  1. app.py +34 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import whisper
2
+ import gradio as gr
3
+ import time
4
+ import os
5
+
6
+ '''model = whisper.load_model("base")
7
+ print(model.device)'''
8
+
9
+
10
+ def speechtotext(tmp_filename, uploaded):
11
+ try:
12
+ source = uploaded if uploaded is not None else tmp_filename
13
+ result = os.system("whisper" + source + " --language Hindi " + " --task translate ")
14
+ return f'Detected language: {Language.make(language=result["language"]).display_name()}\n\n ' \
15
+ f'You said: {result["text"]}'
16
+ except:
17
+ return "Unable to generate translation"
18
+
19
+
20
+ gr.Interface(
21
+
22
+ title="NS-AI-Labs Custom Whisper",
23
+ thumbnail="https://cdn.openai.com/whisper/asr-summary-of-model-architecture-desktop.svg",
24
+ css="""
25
+ .gr-prose p{text-align: center;}
26
+ .gr-button {background: black;color: white}
27
+ """,
28
+ description="we customised whisper with some additional ASR layers , speak in any language we are here to get it "
29
+ "recognised !",
30
+ fn=speechtotext,
31
+ inputs=[
32
+ gr.Audio(label="Record your voice on your mic", source="microphone", type="filepath"),
33
+ gr.Audio(source="upload", type="filepath", label="Upload Audio")],
34
+ outputs="text").launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ langcodes[data]
2
+ git+https://github.com/openai/whisper.git