diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..26d33521af10bcc7fd8cea344038eaaeb78d0ef5
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/asr-test.iml b/.idea/asr-test.iml
new file mode 100644
index 0000000000000000000000000000000000000000..94ee25793569b5d8309754955647b9bd69a3728d
--- /dev/null
+++ b/.idea/asr-test.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a52c3a3349fc8a4fd5f996da4b7620f40f3e4753
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..28b0dd4f2cda51ba4121f0331633d84d88e2a3ba
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3c2a80f0d3bcdb0b0c96f52705a9b5f10e491718
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app.py b/app.py
index b77442456043cc218b90ec67ea09fae33c3118f2..c771df9ec8c2a794dc0d44d87a44ec8085f95073 100644
--- a/app.py
+++ b/app.py
@@ -1,25 +1,50 @@
+import os
import gradio as gr
-# import os
-# os.environ.get("HF_REPO_ID")
-# Define the function that will process the audio input
-def process_audio(audio):
- # Here you can add your audio processing code
- return f"Received audio file: {audio}"
+import librosa
+import torch
+import torchaudio
+import numpy as np
+
+from transformers import WhisperTokenizer
+from transformers import WhisperProcessor
+from transformers import WhisperFeatureExtractor
+from transformers import WhisperForConditionalGeneration
+
+device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
+
+model_path = os.environ.get("HF_REPO_ID")
+access_token = os.environ.get("HF_TOKEN")
+
+feature_extractor = WhisperFeatureExtractor.from_pretrained(model_path, token=access_token)
+tokenizer = WhisperTokenizer.from_pretrained(model_path, token=access_token)
+processor = WhisperProcessor.from_pretrained(model_path, token=access_token)
+model = WhisperForConditionalGeneration.from_pretrained(model_path, token=access_token).to(device)
+
+
+def transcribe_audio(file_path):
+ speech_array, sampling_rate = torchaudio.load(file_path, format="wav")
+ speech_array = speech_array[0].numpy()
+ speech_array = librosa.resample(np.asarray(speech_array), orig_sr=sampling_rate, target_sr=16000)
+ input_features = feature_extractor(speech_array, sampling_rate=16000, return_tensors="pt").input_features
+
+ # batch = processor.feature_extractor.pad(input_features, return_tensors="pt")
+ predicted_ids = model.generate(inputs=input_features.to(device))[0]
+
+ transcription = processor.decode(predicted_ids, skip_special_tokens=True)
+
+ return transcription
+
# Create a list of example audio files
-examples = [
- ["https://huggingface.co/MedAiHealth/BanglaASR-MedAI/resolve/main/wav/sample_1.wav"],
- ["https://huggingface.co/MedAiHealth/BanglaASR-MedAI/resolve/main/wav/sample_2.wav"],
- ["https://huggingface.co/MedAiHealth/BanglaASR-MedAI/resolve/main/wav/sample_3.wav"]
-]
+examples = [f"test_sample/{x}" for x in os.listdir("test_sample")]
# Create the Gradio interface
interface = gr.Interface(
- fn=process_audio,
+ fn=transcribe_audio,
inputs=gr.Audio(sources="microphone", type="filepath"),
outputs=gr.Textbox(),
examples=examples
)
# Launch the interface
-interface.launch()
\ No newline at end of file
+interface.launch()
diff --git a/test_sample/2022_05_23-05_20_09.544938_file_file.wav b/test_sample/2022_05_23-05_20_09.544938_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..2cac6b0c6e1e57d8e06b445a253dda10a408b21e
Binary files /dev/null and b/test_sample/2022_05_23-05_20_09.544938_file_file.wav differ
diff --git a/test_sample/2022_06_28-12_01_43.552306_file_file.wav b/test_sample/2022_06_28-12_01_43.552306_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..95e9a6b1a65c05af73e5a7d0d32702f885705cce
Binary files /dev/null and b/test_sample/2022_06_28-12_01_43.552306_file_file.wav differ
diff --git a/test_sample/2022_06_28-17_12_43.524460_file_file.wav b/test_sample/2022_06_28-17_12_43.524460_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..2e998d179107191a3c8dea7e41623b8fde2d4d8d
Binary files /dev/null and b/test_sample/2022_06_28-17_12_43.524460_file_file.wav differ
diff --git a/test_sample/2022_06_28-17_49_39.887762_file_file.wav b/test_sample/2022_06_28-17_49_39.887762_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..49e6a6f2d60b755454d066c4c3c32e9aea71a684
Binary files /dev/null and b/test_sample/2022_06_28-17_49_39.887762_file_file.wav differ
diff --git a/test_sample/2022_06_28-18_21_58.444725_file_file.wav b/test_sample/2022_06_28-18_21_58.444725_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..545aa0c8f0be795501a23ab0f4eec51159326078
Binary files /dev/null and b/test_sample/2022_06_28-18_21_58.444725_file_file.wav differ
diff --git a/test_sample/2022_08_12-09_24_04.719303_file_file.wav b/test_sample/2022_08_12-09_24_04.719303_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..447de92e32677e3d195d7bb4922191065c4d327f
Binary files /dev/null and b/test_sample/2022_08_12-09_24_04.719303_file_file.wav differ
diff --git a/test_sample/2022_08_20-09_51_45.786068_file_file.wav b/test_sample/2022_08_20-09_51_45.786068_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..7b59432ce28394e4c6d077b84f194eae297bb51f
Binary files /dev/null and b/test_sample/2022_08_20-09_51_45.786068_file_file.wav differ
diff --git a/test_sample/2023_01_07-18_27_19.712794_file_file.wav b/test_sample/2023_01_07-18_27_19.712794_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..510ec1f41db4dc8b094616158f6f29ace4c86be8
Binary files /dev/null and b/test_sample/2023_01_07-18_27_19.712794_file_file.wav differ
diff --git a/test_sample/2023_01_08-07_31_45.978198_file_file.wav b/test_sample/2023_01_08-07_31_45.978198_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..d72a70486629a4acbf6f172310822d76cf9f352c
Binary files /dev/null and b/test_sample/2023_01_08-07_31_45.978198_file_file.wav differ
diff --git a/test_sample/2023_01_08-08_10_06.068597_file_file.wav b/test_sample/2023_01_08-08_10_06.068597_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..450f711176b0173d0007fa510e9f164e15254b07
Binary files /dev/null and b/test_sample/2023_01_08-08_10_06.068597_file_file.wav differ
diff --git a/test_sample/2023_01_08-08_29_40.932774_file_file.wav b/test_sample/2023_01_08-08_29_40.932774_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..f438f0f0d9fff45dbad1f78270918eb271fde913
Binary files /dev/null and b/test_sample/2023_01_08-08_29_40.932774_file_file.wav differ
diff --git a/test_sample/2023_01_08-12_28_25.997920_file_file.wav b/test_sample/2023_01_08-12_28_25.997920_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..4f2c9d30daec045e1dee679cbbac333b530fc2ee
Binary files /dev/null and b/test_sample/2023_01_08-12_28_25.997920_file_file.wav differ
diff --git a/test_sample/2023_01_08-20_29_39.120658_file_file.wav b/test_sample/2023_01_08-20_29_39.120658_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..6850a0179ee4796733d3cdd46db0f059f5911f60
Binary files /dev/null and b/test_sample/2023_01_08-20_29_39.120658_file_file.wav differ
diff --git a/test_sample/2023_01_09-03_48_06.242548_file_file.wav b/test_sample/2023_01_09-03_48_06.242548_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..9b9c42028663ae2ee15a5148be848f8d3c39bf56
Binary files /dev/null and b/test_sample/2023_01_09-03_48_06.242548_file_file.wav differ
diff --git a/test_sample/2023_01_09-16_31_24.687076_file_file.wav b/test_sample/2023_01_09-16_31_24.687076_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..5b91e76e3afd49871b825ee4cc9adfb1b5a2d706
Binary files /dev/null and b/test_sample/2023_01_09-16_31_24.687076_file_file.wav differ
diff --git a/test_sample/2023_01_09-17_44_35.401574_file_file.wav b/test_sample/2023_01_09-17_44_35.401574_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..f806147ee4baef489ea36d105040dbea956c8a19
Binary files /dev/null and b/test_sample/2023_01_09-17_44_35.401574_file_file.wav differ
diff --git a/test_sample/2023_01_09-18_00_55.258972_file_file.wav b/test_sample/2023_01_09-18_00_55.258972_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..1954b9bd5211f1f99b411dcb265899aea8cb0c1a
Binary files /dev/null and b/test_sample/2023_01_09-18_00_55.258972_file_file.wav differ
diff --git a/test_sample/2023_01_11-18_13_20.938188_file_file.wav b/test_sample/2023_01_11-18_13_20.938188_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..6e856ba2d6860578dcf06a0afed6fb0fb4b2e7a2
Binary files /dev/null and b/test_sample/2023_01_11-18_13_20.938188_file_file.wav differ
diff --git a/test_sample/2023_01_12-10_26_35.292442_file_file.wav b/test_sample/2023_01_12-10_26_35.292442_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..3e236e18389425649f2ecc1fc0a5cbce55c1fa24
Binary files /dev/null and b/test_sample/2023_01_12-10_26_35.292442_file_file.wav differ
diff --git a/test_sample/2023_01_21-13_00_39.729777_file_file.wav b/test_sample/2023_01_21-13_00_39.729777_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..9288b60128d9f9396e0ae2c545394e1f715fd30e
Binary files /dev/null and b/test_sample/2023_01_21-13_00_39.729777_file_file.wav differ
diff --git a/test_sample/2023_01_21-14_33_17.981865_file_file.wav b/test_sample/2023_01_21-14_33_17.981865_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..e5dec756c77fdec6cc3fac980b37c08f9a250246
Binary files /dev/null and b/test_sample/2023_01_21-14_33_17.981865_file_file.wav differ
diff --git a/test_sample/2023_01_22-06_01_11.350828_file_file.wav b/test_sample/2023_01_22-06_01_11.350828_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..2778231476c470ed8b2241306668c90a4949f8e3
Binary files /dev/null and b/test_sample/2023_01_22-06_01_11.350828_file_file.wav differ
diff --git a/test_sample/2023_01_22-12_44_52.548517_file_file.wav b/test_sample/2023_01_22-12_44_52.548517_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..d0a8711056862e7eea8007eb1b0e598f5ab71cd5
Binary files /dev/null and b/test_sample/2023_01_22-12_44_52.548517_file_file.wav differ
diff --git a/test_sample/2023_01_22-16_11_54.653583_file_file.wav b/test_sample/2023_01_22-16_11_54.653583_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..f0f2df8c0dd6d4c89becdd329f32155209f467a1
Binary files /dev/null and b/test_sample/2023_01_22-16_11_54.653583_file_file.wav differ
diff --git a/test_sample/2023_01_23-09_53_23.863114_file_file.wav b/test_sample/2023_01_23-09_53_23.863114_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..c10994fd7e6684abb27f7e690fd3bb99e72be5e8
Binary files /dev/null and b/test_sample/2023_01_23-09_53_23.863114_file_file.wav differ
diff --git a/test_sample/2023_01_23-10_29_20.715050_file_file.wav b/test_sample/2023_01_23-10_29_20.715050_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..5fb78abd8d80e269f418360a31dd5e66281615a8
Binary files /dev/null and b/test_sample/2023_01_23-10_29_20.715050_file_file.wav differ
diff --git a/test_sample/2023_01_23-10_46_13.330743_file_file.wav b/test_sample/2023_01_23-10_46_13.330743_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..bc3a7c0b646616e1d593d5bc7597c4b2edd4d409
Binary files /dev/null and b/test_sample/2023_01_23-10_46_13.330743_file_file.wav differ
diff --git a/test_sample/2023_01_25-08_23_48.788537_file_file.wav b/test_sample/2023_01_25-08_23_48.788537_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..34624ae6100e4d58e76c93a89ebe2e02a710dfa6
Binary files /dev/null and b/test_sample/2023_01_25-08_23_48.788537_file_file.wav differ
diff --git a/test_sample/2023_01_25-18_09_11.098808_file_file.wav b/test_sample/2023_01_25-18_09_11.098808_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..04290e3990370ac95ad70841f6eaed0d56bb5636
Binary files /dev/null and b/test_sample/2023_01_25-18_09_11.098808_file_file.wav differ
diff --git a/test_sample/2023_01_26-06_09_56.551890_file_file.wav b/test_sample/2023_01_26-06_09_56.551890_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..0e4d5d40c179185284b139983b3379d0403eaf11
Binary files /dev/null and b/test_sample/2023_01_26-06_09_56.551890_file_file.wav differ
diff --git a/test_sample/2023_01_31-04_57_39.844268_file_file.wav b/test_sample/2023_01_31-04_57_39.844268_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..88ceca63729c16212464dd1a5df953dd37033fed
Binary files /dev/null and b/test_sample/2023_01_31-04_57_39.844268_file_file.wav differ
diff --git a/test_sample/2023_02_05-20_33_11.645244_file_file.wav b/test_sample/2023_02_05-20_33_11.645244_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..3f5e8154b91de6971eefec0beef699fbf16546bf
Binary files /dev/null and b/test_sample/2023_02_05-20_33_11.645244_file_file.wav differ
diff --git a/test_sample/2023_02_16-18_58_28.709781_file_file.wav b/test_sample/2023_02_16-18_58_28.709781_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..ddbe365abc6c45f90337641b2a0cfbd7771cbb0e
Binary files /dev/null and b/test_sample/2023_02_16-18_58_28.709781_file_file.wav differ
diff --git a/test_sample/2023_02_17-05_04_12.901097_file_file.wav b/test_sample/2023_02_17-05_04_12.901097_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..71896817b192aff618059945a5e111bf81c4132c
Binary files /dev/null and b/test_sample/2023_02_17-05_04_12.901097_file_file.wav differ
diff --git a/test_sample/2023_02_19-18_05_10.510147_file_file.wav b/test_sample/2023_02_19-18_05_10.510147_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..2af65da6bd6866ce467cfd113b968a7398f9d337
Binary files /dev/null and b/test_sample/2023_02_19-18_05_10.510147_file_file.wav differ
diff --git a/test_sample/2023_02_19-18_11_18.278859_file_file.wav b/test_sample/2023_02_19-18_11_18.278859_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..c06a5319c6ed2b5f9cf04c146dd1734ab34fe010
Binary files /dev/null and b/test_sample/2023_02_19-18_11_18.278859_file_file.wav differ
diff --git a/test_sample/2023_02_19-19_52_46.335251_file_file.wav b/test_sample/2023_02_19-19_52_46.335251_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..c261fae1519feebaa38cca681f812f03a721af3c
Binary files /dev/null and b/test_sample/2023_02_19-19_52_46.335251_file_file.wav differ
diff --git a/test_sample/2023_02_19-21_05_48.788175_file_file.wav b/test_sample/2023_02_19-21_05_48.788175_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..a3da01f98f04fd3ebbcb2c79111041bcc3d44f14
Binary files /dev/null and b/test_sample/2023_02_19-21_05_48.788175_file_file.wav differ
diff --git a/test_sample/2023_02_20-05_58_04.804689_file_file.wav b/test_sample/2023_02_20-05_58_04.804689_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..dc9510a272125e8e75e0abf5419468204acd9be6
Binary files /dev/null and b/test_sample/2023_02_20-05_58_04.804689_file_file.wav differ
diff --git a/test_sample/2023_02_21-16_15_49.133971_file_file.wav b/test_sample/2023_02_21-16_15_49.133971_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..deec24f7c5b6833772ea1a2ebc8957015652ddb7
Binary files /dev/null and b/test_sample/2023_02_21-16_15_49.133971_file_file.wav differ
diff --git a/test_sample/2023_02_21-16_17_04.681508_file_file.wav b/test_sample/2023_02_21-16_17_04.681508_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..26026d9c7e649788333544305e1633dd52f16eab
Binary files /dev/null and b/test_sample/2023_02_21-16_17_04.681508_file_file.wav differ
diff --git a/test_sample/2023_02_21-18_15_05.508112_file_file.wav b/test_sample/2023_02_21-18_15_05.508112_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..8a059387ce257d54b06c881f42b3ccd631aa98ea
Binary files /dev/null and b/test_sample/2023_02_21-18_15_05.508112_file_file.wav differ
diff --git a/test_sample/2023_02_21-18_32_41.623443_file_file.wav b/test_sample/2023_02_21-18_32_41.623443_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..0092cf48b2e9d83f387d07666c687a9304c2ddf1
Binary files /dev/null and b/test_sample/2023_02_21-18_32_41.623443_file_file.wav differ
diff --git a/test_sample/2023_02_23-14_58_31.544142_file_file.wav b/test_sample/2023_02_23-14_58_31.544142_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..ee5dee1ebff5810f72b66cada6984c7746d0eaa0
Binary files /dev/null and b/test_sample/2023_02_23-14_58_31.544142_file_file.wav differ
diff --git a/test_sample/2023_03_05-17_03_33.254051_file_file.wav b/test_sample/2023_03_05-17_03_33.254051_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..d44f6eebd40f4a7792e264643b79ddabe367a2f7
Binary files /dev/null and b/test_sample/2023_03_05-17_03_33.254051_file_file.wav differ
diff --git a/test_sample/2023_03_10-15_58_11.547424_file_file.wav b/test_sample/2023_03_10-15_58_11.547424_file_file.wav
new file mode 100644
index 0000000000000000000000000000000000000000..e6275e2a471733209306e42f90100c9a4cb56bc6
Binary files /dev/null and b/test_sample/2023_03_10-15_58_11.547424_file_file.wav differ