prem
prem

Reputation: 1

how to implement Speech To Text using python houndify?

I am new to houndify,i have been creating STT(Speech To Text) process.i have an idea to create it using python.I choosed houndify python 2.7 SDK.I have got the client id and client key of houndify service.So how can i proceed to Speech To Text conversion?.Please solve it in step by step process?

Upvotes: 0

Views: 2493

Answers (1)

aisfo
aisfo

Reputation: 21

The Python SDK contains two sample scripts that show how to send voice queries to Houndify: sample_stdin.py and sample_wave.py. Regardless of the source of audio, the steps are following:

  1. initialize houndify.StreamingHoundClient object with clientID, clientKey and some userID (can be "test_user" during development, but ideally should correspond to your enduser)
  2. extend houndify.HoundListener class
  3. pass the instance of your listener to StreamingHoundClient object's start() method
  4. read audio chunks (8/16 kHz mono 16-bit little-endian PCM samples) in a loop and feed it into client: client.fill(samples)
  5. call client.finish() after streaming is done

You can find more details about the SDK (including information about setting request info fields) here: https://docs.houndify.com/sdks/docs/python .

Here's a simple script that reads audio from stdin and just prints partial transcripts, final response or error message:

import sys
import houndify


class MyListener(houndify.HoundListener):

  def onPartialTranscript(self, transcript):
    print "Partial transcript: " + transcript

  def onFinalResponse(self, response):
    print "Final response: " + str(response)

  def onError(self, err):
    print "Error: " + str(err)


client = houndify.StreamingHoundClient(<CLIENT_ID>, <CLIENT_KEY>, "test_user", sampleRate = 8000)

BUFFER_SIZE = 512

client.start(MyListener())

while True:
  samples = sys.stdin.read(BUFFER_SIZE)
  if len(samples) == 0: break

  finished = client.fill(samples)
  if finished: break

client.finish()

Upvotes: 2

Related Questions