Python
About Lesson

Speech to Text using Wit.Ai

Wit.ai is a natural language interface for applications’ ability to turn sentences into organized data. It is also pretty accurate for speech recognition and audio transcription.

Follow the below steps to use wit.ai:

  1. Open wit.ai in a web browser.
  2. Login using your GitHub or Facebook account. if you don’t have one, create one.
  3. Click on the New App button to create a new app.
  4. In the Settings tab, you will find Server Access Token and Client Access Token. Copy it, as it will be needed for authentication in the python script.

Run the following command to install wit packages.

pip3 install wit

Wit will be successfully be installed.

Speech to text using Wit.Ai (Audio file)

from wit import Wit


access_token = "Your access token"
client = Wit(access_token)

resp = None
with open('avatar.wav', 'rb') as f:
  resp = client.speech(f, None, {'Content-Type': 'audio/wav'})
print(f'Yay, got Wit.ai response: {str(resp)}')