Spaces:
Build error
Build error
Hunzla
commited on
Commit
•
761c854
0
Parent(s):
Duplicate from Hunzla/whisperaudio
Browse files- .gitattributes +35 -0
- README.md +14 -0
- app.py +65 -0
- requirements.txt +3 -0
- tasks.json +129 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Whisperaudio
|
3 |
+
emoji: 🚀
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: red
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.39.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: openrail
|
11 |
+
duplicated_from: Hunzla/whisperaudio
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
transcript_pipe = pipeline("automatic-speech-recognition", model="ihanif/whisper-medium-urdu")
|
3 |
+
from difflib import SequenceMatcher
|
4 |
+
import json
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
with open("tasks.json", "r",encoding="utf-8") as json_file:
|
10 |
+
urdu_data = json.load(json_file)
|
11 |
+
# List of commands
|
12 |
+
# commands = [
|
13 |
+
# "نمائندے ایجنٹ نمائندہ",
|
14 |
+
# " سم ایکٹیویٹ ",
|
15 |
+
# " سم بلاک بند ",
|
16 |
+
# "موبائل پیکیجز انٹرنیٹ پیکیج",
|
17 |
+
# " چالان جمع چلان",
|
18 |
+
# " گانا "
|
19 |
+
# ]
|
20 |
+
# replies = [
|
21 |
+
# 1,2,
|
22 |
+
# ]
|
23 |
+
# Function to find the most similar command
|
24 |
+
def find_most_similar_command(statement, command_list):
|
25 |
+
best_match = None
|
26 |
+
highest_similarity = 0
|
27 |
+
for index,file_list in command_list.items():
|
28 |
+
for command in file_list:
|
29 |
+
similarity = SequenceMatcher(None, statement, command).ratio()
|
30 |
+
print(index,"similarity",similarity)
|
31 |
+
if similarity > highest_similarity:
|
32 |
+
highest_similarity = similarity
|
33 |
+
best_match = command
|
34 |
+
reply=index
|
35 |
+
return best_match,reply
|
36 |
+
|
37 |
+
def transcribe_the_command(audio,menu_id,abc):
|
38 |
+
import soundfile as sf
|
39 |
+
sample_rate, audio_data = audio
|
40 |
+
file_name = "recorded_audio.wav"
|
41 |
+
sf.write(file_name, audio_data, sample_rate)
|
42 |
+
# Convert stereo to mono by averaging the two channels
|
43 |
+
print(menu_id)
|
44 |
+
|
45 |
+
transcript = asr_pipe(file_name)["text"]
|
46 |
+
commands=urdu_data[menu_id]
|
47 |
+
print(commands)
|
48 |
+
most_similar_command,reply = find_most_similar_command(transcript, commands)
|
49 |
+
print(f"Given Statement: {transcript}")
|
50 |
+
print(f"Most Similar Command: {most_similar_command}\n")
|
51 |
+
print(reply)
|
52 |
+
return reply
|
53 |
+
# get_text_from_voice("urdu.wav")
|
54 |
+
import gradio as gr
|
55 |
+
|
56 |
+
|
57 |
+
iface = gr.Interface(
|
58 |
+
fn=transcribe_the_command,
|
59 |
+
inputs=[gr.inputs.Audio(label="Recorded Audio",source="microphone"),gr.inputs.Textbox(label="menu_id"),gr.inputs.Textbox(label="dfs")],
|
60 |
+
outputs="text",
|
61 |
+
title="Whisper Small Urdu Command",
|
62 |
+
description="Realtime demo for Urdu speech recognition using a fine-tuned Whisper small model and outputting the estimated command on the basis of speech transcript.",
|
63 |
+
)
|
64 |
+
|
65 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers[torch]
|
3 |
+
soundfile
|
tasks.json
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"1": {
|
3 |
+
"99":["کیا آپ میری مدد کر سکتے ہیں","مجھے نمائندے سے بات کرنی ہے","مجھے مدد کی ضرورت ہے","مجھے ایجنٹ سے بات کرنی ہے۔"],
|
4 |
+
"10":["آرڈر کریں ","آرڈر پلیس کر دیں","رکھیں آرڈر","میں نے آرڈر کرنا ہے۔","مجھے آرڈر کرنا ہے", "مجھے پیزا آرڈر کرنی ہے",
|
5 |
+
"مجھے پیزا آرڈر کرنے ہے",
|
6 |
+
"پیزا مجھے آرڈر کرنا ہے",
|
7 |
+
"مجھے پیزا کرنا آرڈر ہے",
|
8 |
+
"پیزا آرڈر مجھے کرنا ہے"]
|
9 |
+
},
|
10 |
+
"10": {
|
11 |
+
"101":[
|
12 |
+
"پیپرونی",
|
13 |
+
"پیپرونی",
|
14 |
+
"پیپرانی",
|
15 |
+
"پپرونی",
|
16 |
+
"پپرونی",
|
17 |
+
"پیپرونی",
|
18 |
+
"پیپرونی",
|
19 |
+
"پیپرونی",
|
20 |
+
"پپرونی",
|
21 |
+
"پیپرانی"
|
22 |
+
],
|
23 |
+
"102":[
|
24 |
+
"چکن تکہ",
|
25 |
+
"چکن تکا",
|
26 |
+
"چکن ٹکہ",
|
27 |
+
"چکن تکہہ",
|
28 |
+
"چکن تیکہ",
|
29 |
+
"چکن تکہ",
|
30 |
+
"چکن تکہ",
|
31 |
+
"چکن تکہ",
|
32 |
+
"چکن تکا",
|
33 |
+
"چکن ٹکا"
|
34 |
+
],
|
35 |
+
"103":[
|
36 |
+
"بیف سپریم",
|
37 |
+
"بیف سپریم",
|
38 |
+
"بیف سپریم",
|
39 |
+
"بیف سپرم",
|
40 |
+
"بیف سپرم",
|
41 |
+
"بیف سوپریم",
|
42 |
+
"بیف سپریم",
|
43 |
+
"بیف سپریم",
|
44 |
+
"بیف سپرم",
|
45 |
+
"بیف سپریم"
|
46 |
+
]
|
47 |
+
},
|
48 |
+
"11": {
|
49 |
+
"111":[ "سات انچ",
|
50 |
+
"سات انچز",
|
51 |
+
"7 انچ",
|
52 |
+
"سات انچھ",
|
53 |
+
"سات انچز",
|
54 |
+
"چھوٹا",
|
55 |
+
"چھوٹی",
|
56 |
+
"سمول",
|
57 |
+
"سمال",
|
58 |
+
"چوٹا"
|
59 |
+
],
|
60 |
+
"112":[ "میڈیم",
|
61 |
+
"میڈیم",
|
62 |
+
"میڈئم",
|
63 |
+
"میڈیمز",
|
64 |
+
"میڈیم",
|
65 |
+
"دس انچ",
|
66 |
+
"دس انچز",
|
67 |
+
"10 انچ",
|
68 |
+
"دس انچھ",
|
69 |
+
"دس انچز"
|
70 |
+
],
|
71 |
+
"113":[
|
72 |
+
"لارج",
|
73 |
+
"لاج",
|
74 |
+
"لارگ",
|
75 |
+
"لارجز",
|
76 |
+
"لارج" ,
|
77 |
+
"تیرہ انچ",
|
78 |
+
"تیرہ انچز",
|
79 |
+
"13 انچ",
|
80 |
+
"تیرہ انچھ",
|
81 |
+
"تیرہ انچز"
|
82 |
+
|
83 |
+
],
|
84 |
+
"114":[
|
85 |
+
|
86 |
+
"ایکس ایل",
|
87 |
+
"اکسٹرا لارج",
|
88 |
+
"اے ایل",
|
89 |
+
"ایکسٹرا لارج",
|
90 |
+
"ای ایل" ,
|
91 |
+
"فیملی سائز",
|
92 |
+
"فیملی سائز",
|
93 |
+
"فیملی سائز",
|
94 |
+
"فاملی سائز",
|
95 |
+
"فیملی سائزز",
|
96 |
+
"سولہ انچ",
|
97 |
+
"سولہ انچز",
|
98 |
+
"16 انچ",
|
99 |
+
"سولہ انچھ",
|
100 |
+
"سولہ انچز"
|
101 |
+
]
|
102 |
+
},
|
103 |
+
"13": {
|
104 |
+
"131": [
|
105 |
+
"پیزا کرسٹ تھن",
|
106 |
+
"پیزا کرسٹ تھن",
|
107 |
+
"پیزا کرست تھن",
|
108 |
+
"پیزا کرسٹ سکن",
|
109 |
+
"پیزا کرسٹ پتلی",
|
110 |
+
"پیزا کرسٹ تھن اینچ",
|
111 |
+
"پیزا تھن کرسٹ",
|
112 |
+
"کرسٹ پیزا تھن",
|
113 |
+
"پیزا کرسٹ تن",
|
114 |
+
"پیزا کرسٹ تھن"
|
115 |
+
],
|
116 |
+
"132":[
|
117 |
+
"پیزا کرسٹ ہینڈ ٹوسٹڈ",
|
118 |
+
"پیزا کرسٹ ہینڈ ٹوسٹڈ",
|
119 |
+
"پیزا کرست ہینڈ ٹوسٹڈ",
|
120 |
+
"پیزا کرسٹ ہینڈ ٹوسٹڈ",
|
121 |
+
"پیزا کرسٹ ہینڈ توستڈ",
|
122 |
+
"پیزا کرسٹ ہینڈ ٹوسٹڈ اینچ",
|
123 |
+
"پیزا ٹوسٹڈ ہینڈ کرسٹ",
|
124 |
+
"کرسٹ ہینڈ پیزا ٹوسٹڈ",
|
125 |
+
"پیزا کرسٹ ہینڈ توستڈ",
|
126 |
+
"پیزا کرسٹ ہینڈ ٹوسٹڈ"
|
127 |
+
]
|
128 |
+
}
|
129 |
+
}
|