Reputation: 141
I'm trying to integrate Jasper(https://github.com/jasperproject/jasper-client) with houndify python sdk. I'm trying to integrate the Houndify in Jasper's Speech to Text engine(https://github.com/jasperproject/jasper-client/blob/master/client/stt.py).
The problem is all the stt engines are defined as inherited class of an abstract class and I need to define an inherited class for Houdify. The transcribe() method returns the transcribbed text, but the Houndify uses a class to return the text.
So how can I include a class(Houndify transcribe class) within a method of inherited class(Houdify stt class) such that the value returned by the class(Houndify transcribe class) should be returned by the method of inherited class?
Code to integrate:
import wave
import houndify
import sys
import time
# The code below will demonstrate how to use streaming audio through Hound
if __name__ == '__main__':
# We'll accept WAV files but it should be straightforward to
# use samples from a microphone or other source
BUFFER_SIZE = 512
CLIENT_ID =
CLIENT_KEY =
#
# Simplest HoundListener; just print out what we receive.
#
# You can use these callbacks to interact with your UI.
#
class MyListener(houndify.HoundListener):
def onFinalResponse(self, response):
transcribed = response['AllResults']
print "\n"
print transcribed[0]['FormattedTranscription']
def onError(self, err):
print "Error: " + str(err)
client = houndify.StreamingHoundClient(CLIENT_ID, CLIENT_KEY, "test_user")
fname = 'whatistheweatherthere.wav'
audio = wave.open(fname)
client.setSampleRate(audio.getframerate())
samples = audio.readframes(BUFFER_SIZE)
finished = False
client.start(MyListener())
while not finished:
finished = client.fill(samples)
samples = audio.readframes(BUFFER_SIZE)
if len(samples) == 0:
break
client.finish()
Code where to be integrated: The above stt.py
Upvotes: 2
Views: 69