From a9dc7920ad5fbb82e905d8c2cfdad95694a57382 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Tue, 6 Oct 2020 17:58:38 +0200 Subject: [PATCH] Removed google bloat --- speech/speech.py | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/speech/speech.py b/speech/speech.py index 3079987..88ae971 100644 --- a/speech/speech.py +++ b/speech/speech.py @@ -4,41 +4,11 @@ from google.cloud import speech as sp class voiceInput(object): recognizer = sr.Recognizer() - commandFunc = None muted = True - def transcribe_voice( self, streamFile ): - cl = sp.SpeechClient() - - with io.open( streamFile, "rb" ) as audioFile: - cont = audioFile.read() - - stream = [cont] - req = ( sp.StreamingRecognizeRequest(audio_content=chunk) for chunk in stream ) - - conf = sp.RecognitionConfig( - encoding = sp.RecognitionConfig.AudioEncoding.LINEAR16, - sample_rate_hertz = 16000, - language_code = "en-US" - ) - - - streamConf = sp.StreamingRecognitionConfig(config=conf) - - responses = cl.streaming_recognize( steamConf, req ) - - for res in responses: - for result in res.results: - for alt in result.alternatives: - print(alt.transcript) - def setMuted( self, setm: bool=True ): self.muted = setm def switchMute( self ): self.setMuted( not self.muted ) - - -vc = voiceInput() -vc.transcribe_voice( "./stream.txt" )