async def asrgooglewordboosting(self, audiouri: str, phrasesetid: str, lang: str) ->…
- User
async def asr_google_word_boosting(self, audio_uri: str, phrase_set_id: str, lang: str) -> str: # Perform ASR using Google API with word boosting. with open(audio_uri, "rb") as audio_file: content = audio_file.read() audio = speech.RecognitionAudio(content=content)
codephrases_data = self.load_phrases_data(lang) phrase_set_name = self.ensure_phrase_set(phrase_set_id, phrases_data) speech_adaptation = speech.SpeechAdaptation(phrase_set_references=[phrase_set_name]) config = speech.RecognitionConfig( encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16, sample_rate_hertz=24000, language_code=lang, enable_automatic_punctuation=True, model="telephony", adaptation=speech_adaptation, ) logger.info( "\nTranscribing using Google ASR with Boosting: -------------------------------------->" ) response = self.speech_client.recognize(config=config, audio=audio) transcript = "" for result in response.results: if result.alternatives[0].transcript == "": #or result.alternatives[0].transcript is None: logger.info( " Model: telephony, Audio: %s\n Transcript: %s", audio_uri, "[Unrecognizable text!]" ) transcript += result.alternatives[0].transcript + " " return "[Unrecognizable text!]" else: logger.info( " Model: telephony, Audio: %s\n Transcript: %s", audio_uri, result.alternatives[0].transcript, ) transcript += str(result.alternatives[0].transcript + " ") return transcript.strip()check if this fucntion is good, because I see that some part of transcription are missing
- Assistant
- User
def split_audio_and_save_chunks( self, audio_path: str, enhanced_dir: str, original_filename: str, noise_remover: bool = False, speech_enhancement: bool = False, max_chunk_length: int = 60000, min_pause_length: int = 1000, ) -> Tuple[List[str], str]:
- Assistant