Removed google bloat

fetchIP
E. Almqvist 4 years ago
parent 57af43c90c
commit a9dc7920ad
  1. 30
      speech/speech.py

@ -4,41 +4,11 @@ from google.cloud import speech as sp
class voiceInput(object): class voiceInput(object):
recognizer = sr.Recognizer() recognizer = sr.Recognizer()
commandFunc = None
muted = True 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 ): def setMuted( self, setm: bool=True ):
self.muted = setm self.muted = setm
def switchMute( self ): def switchMute( self ):
self.setMuted( not self.muted ) self.setMuted( not self.muted )
vc = voiceInput()
vc.transcribe_voice( "./stream.txt" )

Loading…
Cancel
Save