Skip to content

Commit

Permalink
minor cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
josancamon19 committed Oct 5, 2024
1 parent 4995a37 commit 0bcefb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions backend/routers/transcribe_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def get_model_name(value):

async def _websocket_util(
websocket: WebSocket, uid: str, language: str = 'en', sample_rate: int = 8000, codec: str = 'pcm8',
channels: int = 1, include_speech_profile: bool = True, new_memory_watch: bool = False,
include_speech_profile: bool = True,
# stt_service: STTService = STTService.deepgram,
):
print('websocket_endpoint', uid, language, sample_rate, codec, channels, include_speech_profile, new_memory_watch)
print('websocket_endpoint', uid, language, sample_rate, codec, include_speech_profile)

# Not when comes from the phone, and only Friend's with 1.0.4
if language == 'en' and sample_rate == 16000 and codec == 'opus':
Expand Down Expand Up @@ -181,11 +181,11 @@ def stream_transcript(segments, _):
# DEEPGRAM
if stt_service == STTService.deepgram:
deepgram_socket = await process_audio_dg(
stream_transcript, 1, language, sample_rate, channels, preseconds=speech_profile_duration
stream_transcript, 1, language, sample_rate, 1, preseconds=speech_profile_duration
)
if speech_profile_duration:
deepgram_socket2 = await process_audio_dg(
stream_transcript, 2, language, sample_rate, channels
stream_transcript, 2, language, sample_rate, 1
)

async def deepgram_socket_send(data):
Expand Down Expand Up @@ -213,7 +213,7 @@ async def deepgram_socket_send(data):
await websocket.close(code=websocket_close_code)
return

decoder = opuslib.Decoder(sample_rate, channels)
decoder = opuslib.Decoder(sample_rate, 1)
websocket_active = True
websocket_close_code = 1001 # Going Away, don't close with good from backend

Expand Down Expand Up @@ -362,9 +362,9 @@ async def _create_memory():
@router.websocket("/v2/listen")
async def websocket_endpoint(
websocket: WebSocket, uid: str, language: str = 'en', sample_rate: int = 8000, codec: str = 'pcm8',
channels: int = 1, include_speech_profile: bool = True, new_memory_watch: bool = False,
channels: int = 1, include_speech_profile: bool = True,
# stt_service: STTService = STTService.deepgram
):
await _websocket_util(
websocket, uid, language, sample_rate, codec, channels, include_speech_profile, new_memory_watch, # stt_service
websocket, uid, language, sample_rate, codec, channels, include_speech_profile, # stt_service
)
8 changes: 4 additions & 4 deletions backend/utils/stt/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import List

import websockets
from deepgram import DeepgramClient, DeepgramClientOptions, LiveTranscriptionEvents, ListenWebSocketClient
from deepgram import DeepgramClient, DeepgramClientOptions, LiveTranscriptionEvents
from deepgram.clients.live.v1 import LiveOptions

import database.notifications as notification_db
Expand Down Expand Up @@ -94,8 +94,7 @@ async def send_initial_file(data: List[List[int]], transcript_socket):


async def process_audio_dg(
stream_transcript, stream_id: int, language: str, sample_rate: int, channels: int,
preseconds: int = 0,
stream_transcript, stream_id: int, language: str, sample_rate: int, channels: int, preseconds: int = 0,
):
print('process_audio_dg', language, sample_rate, channels, preseconds)

Expand Down Expand Up @@ -342,7 +341,8 @@ async def on_message():
raise # Re-raise the exception to be handled by the caller


async def process_audio_speechmatics(stream_transcript, stream_id: int, sample_rate: int, language: str, preseconds: int = 0):
async def process_audio_speechmatics(stream_transcript, stream_id: int, sample_rate: int, language: str,
preseconds: int = 0):
api_key = os.getenv('SPEECHMATICS_API_KEY')
uri = 'wss://eu2.rt.speechmatics.com/v2'

Expand Down

0 comments on commit 0bcefb8

Please sign in to comment.