Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,7 @@ import soundfile as sf
|
|
17 |
from indic_transliteration import sanscript
|
18 |
from indic_transliteration.sanscript import transliterate
|
19 |
import warnings
|
|
|
20 |
warnings.filterwarnings("ignore")
|
21 |
|
22 |
# ---------------- CONFIG ---------------- #
|
@@ -87,6 +88,7 @@ SENTENCE_BANK = {
|
|
87 |
# ---------------- MODEL CACHE ---------------- #
|
88 |
asr_models = {}
|
89 |
|
|
|
90 |
def load_asr_model(language):
|
91 |
"""Load ASR model for specific language - PRIMARY MODELS ONLY"""
|
92 |
if language not in asr_models:
|
@@ -162,6 +164,7 @@ def preprocess_audio(audio_path, target_sr=16000):
|
|
162 |
print(f"Audio preprocessing error: {e}")
|
163 |
return None, None
|
164 |
|
|
|
165 |
def transcribe_audio(audio_path, language, initial_prompt="", force_language=True):
|
166 |
"""Transcribe audio using loaded models"""
|
167 |
try:
|
@@ -322,6 +325,7 @@ def get_pronunciation_score(wer_val, cer_val):
|
|
322 |
return "๐ช Keep Trying! (<40%)", "Don't give up! Practice makes perfect."
|
323 |
|
324 |
# ---------------- MAIN FUNCTION ---------------- #
|
|
|
325 |
def compare_pronunciation(audio, language_choice, intended_sentence):
|
326 |
"""Main function to compare pronunciation"""
|
327 |
print(f"๐ Starting analysis with language: {language_choice}")
|
@@ -543,8 +547,9 @@ if __name__ == "__main__":
|
|
543 |
print("๐ Starting Multilingual Pronunciation Trainer with LARGE models...")
|
544 |
print(f"๐ง Device: {DEVICE}")
|
545 |
print(f"๐ง PyTorch version: {torch.__version__}")
|
546 |
-
print("๐ฆ Models will be loaded on-demand
|
547 |
print("โก Using AI4Bharat LARGE models for maximum accuracy!")
|
|
|
548 |
|
549 |
demo = create_interface()
|
550 |
demo.launch(
|
|
|
17 |
from indic_transliteration import sanscript
|
18 |
from indic_transliteration.sanscript import transliterate
|
19 |
import warnings
|
20 |
+
import spaces
|
21 |
warnings.filterwarnings("ignore")
|
22 |
|
23 |
# ---------------- CONFIG ---------------- #
|
|
|
88 |
# ---------------- MODEL CACHE ---------------- #
|
89 |
asr_models = {}
|
90 |
|
91 |
+
@spaces.GPU
|
92 |
def load_asr_model(language):
|
93 |
"""Load ASR model for specific language - PRIMARY MODELS ONLY"""
|
94 |
if language not in asr_models:
|
|
|
164 |
print(f"Audio preprocessing error: {e}")
|
165 |
return None, None
|
166 |
|
167 |
+
@spaces.GPU
|
168 |
def transcribe_audio(audio_path, language, initial_prompt="", force_language=True):
|
169 |
"""Transcribe audio using loaded models"""
|
170 |
try:
|
|
|
325 |
return "๐ช Keep Trying! (<40%)", "Don't give up! Practice makes perfect."
|
326 |
|
327 |
# ---------------- MAIN FUNCTION ---------------- #
|
328 |
+
@spaces.GPU
|
329 |
def compare_pronunciation(audio, language_choice, intended_sentence):
|
330 |
"""Main function to compare pronunciation"""
|
331 |
print(f"๐ Starting analysis with language: {language_choice}")
|
|
|
547 |
print("๐ Starting Multilingual Pronunciation Trainer with LARGE models...")
|
548 |
print(f"๐ง Device: {DEVICE}")
|
549 |
print(f"๐ง PyTorch version: {torch.__version__}")
|
550 |
+
print("๐ฆ Models will be loaded on-demand with GPU acceleration...")
|
551 |
print("โก Using AI4Bharat LARGE models for maximum accuracy!")
|
552 |
+
print("๐ฎ GPU functions decorated with @spaces.GPU for HuggingFace Spaces")
|
553 |
|
554 |
demo = create_interface()
|
555 |
demo.launch(
|