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" )