Skip to content

Commit

Permalink
tested
Browse files Browse the repository at this point in the history
  • Loading branch information
0xzre committed Aug 17, 2024
1 parent c758076 commit 91c8d5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 3 additions & 3 deletions backend/routers/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import opuslib

from utils.redis_utils import get_user_speech_profile, get_user_speech_profile_duration
from utils.stt.deepgram_util import process_audio_dg, send_initial_file2, transcribe_file_deepgram, convert_audio_bytes_to_resampled_bytes
from utils.stt.deepgram_util import process_audio_dg, send_initial_file2, transcribe_file_deepgram
from utils.stt.vad import VADIterator, model, get_speech_state, SpeechState, vad_is_empty, is_speech_present

router = APIRouter()
Expand Down Expand Up @@ -54,7 +54,7 @@ async def _websocket_util(
websocket_active = True
duration = 0
is_speech_active = False
speech_timeout = 0.7
speech_timeout = 0.7 # Good for now but better dynamically adjust it by user behaviour
last_speech_time = 0
try:
if language == 'en' and codec == 'opus' and include_speech_profile:
Expand All @@ -77,7 +77,7 @@ async def _websocket_util(
await websocket.close()
return

threshold = 0.7
threshold = 0.6
vad_iterator = VADIterator(model, sampling_rate=sample_rate, threshold=threshold)
window_size_samples = 256 if sample_rate == 8000 else 512
if codec == 'opus':
Expand Down
5 changes: 0 additions & 5 deletions backend/utils/stt/vad.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
(get_speech_timestamps, save_audio, read_audio, VADIterator, collect_chunks) = utils


class SpeechState(str, Enum):
has_speech = 'has_speech'
no_speech = 'no_speech'


def get_speech_state(data, vad_iterator, window_size_samples=256):
has_start, has_end = False, False
for i in range(0, len(data), window_size_samples):
Expand Down

0 comments on commit 91c8d5d

Please sign in to comment.