Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,9 @@ from waitress import serve
|
|
9 |
|
10 |
app = Flask(__name__)
|
11 |
|
12 |
-
# Load Whisper ASR Model for
|
13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
14 |
-
asr_model = pipeline("automatic-speech-recognition", model="openai/whisper-
|
15 |
|
16 |
# Function to generate voice prompts
|
17 |
def generate_audio_prompt(text, filename):
|
@@ -54,7 +54,7 @@ def convert_to_wav(input_path, output_path):
|
|
54 |
# Function to check if audio contains actual speech
|
55 |
def is_silent_audio(audio_path):
|
56 |
audio = AudioSegment.from_wav(audio_path)
|
57 |
-
nonsilent_parts = detect_nonsilent(audio, min_silence_len=
|
58 |
return len(nonsilent_parts) == 0
|
59 |
|
60 |
@app.route("/")
|
|
|
9 |
|
10 |
app = Flask(__name__)
|
11 |
|
12 |
+
# Load Whisper ASR Model for Better Speed & Accuracy
|
13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
14 |
+
asr_model = pipeline("automatic-speech-recognition", model="openai/whisper-small", device=0 if device == "cuda" else -1) # Small model for faster inference
|
15 |
|
16 |
# Function to generate voice prompts
|
17 |
def generate_audio_prompt(text, filename):
|
|
|
54 |
# Function to check if audio contains actual speech
|
55 |
def is_silent_audio(audio_path):
|
56 |
audio = AudioSegment.from_wav(audio_path)
|
57 |
+
nonsilent_parts = detect_nonsilent(audio, min_silence_len=300, silence_thresh=audio.dBFS-16) # Reduced silence duration
|
58 |
return len(nonsilent_parts) == 0
|
59 |
|
60 |
@app.route("/")
|