Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,6 +30,12 @@ def transcribe_audio(audio_path, original_text):
|
|
30 |
if sample_rate != 16000:
|
31 |
transform = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)
|
32 |
waveform = transform(waveform)
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
input_values = processor(waveform.squeeze().numpy(), sampling_rate=16000, return_tensors="pt").input_values
|
34 |
|
35 |
# 2. Transcribe with AI4Bharat model
|
@@ -57,6 +63,8 @@ def transcribe_audio(audio_path, original_text):
|
|
57 |
except Exception as e:
|
58 |
return {"error": str(e)}
|
59 |
|
|
|
|
|
60 |
with gr.Blocks() as app:
|
61 |
gr.Markdown("## 🗣️ Hindi Reading & Pronunciation Practice App (AI4Bharat Model)")
|
62 |
|
|
|
30 |
if sample_rate != 16000:
|
31 |
transform = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)
|
32 |
waveform = transform(waveform)
|
33 |
+
|
34 |
+
# --- Amplify voice intensity here ---
|
35 |
+
GAIN = 1.5 # You can adjust this value (1.0 = unchanged, 2.0 = double)
|
36 |
+
waveform = waveform * GAIN
|
37 |
+
waveform = torch.clamp(waveform, -1.0, 1.0) # Avoid clipping/distortion
|
38 |
+
|
39 |
input_values = processor(waveform.squeeze().numpy(), sampling_rate=16000, return_tensors="pt").input_values
|
40 |
|
41 |
# 2. Transcribe with AI4Bharat model
|
|
|
63 |
except Exception as e:
|
64 |
return {"error": str(e)}
|
65 |
|
66 |
+
return {"error": str(e)}
|
67 |
+
|
68 |
with gr.Blocks() as app:
|
69 |
gr.Markdown("## 🗣️ Hindi Reading & Pronunciation Practice App (AI4Bharat Model)")
|
70 |
|