Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pywit

> 编程语言
Open source

Python library for Wit.ai

1.5K stars0 likes0 views
WebsiteGitHub

About

Python library for Wit.ai

pywit

pywit is the Python SDK for Wit.ai.

Install

Using pip:

pip install wit

From source:

git clone https://github.com/wit-ai/pywit
pip install .

Usage

See the examples folder for examples.

API

Versioning

The default API version is 20200513. You can target a specific version by setting the env variable WIT_API_VERSION.

Overview

pywit provides a Wit class with the following methods:

  • message - the Wit message API
  • speech - the Wit speech API
  • interactive - starts an interactive conversation with your bot

Wit class

The Wit constructor takes the following parameters:

  • access_token - the access token of your Wit instance

A minimal example looks like this:

from wit import Wit

client = Wit(access_token)
client.message('set an alarm tomorrow at 7am')

.message()

The Wit message API.

Takes the following parameters:

  • msg - the text you want Wit.ai to extract the information from

Example:

resp = client.message('what is the weather in London?')
print('Yay, got Wit.ai response: ' + str(resp))

.speech()

The Wit speech API.

Takes the following parameters:

  • audio_file - a file handler opened in binary mode
  • headers - (optional) the dict of headers (e.g. "Content-Type")

Example:

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

.interactive()

Starts an interactive conversation with your bot.

Example:

client.interactive()

See the docs for more information.

Logging

Default logging is to STDOUT with INFO level.

You can set your logging level as follows:

from wit import Wit
import logging
client = Wit(token)
client.logger.setLevel(logging.WARNING)

You can also specify a custom logger object in the Wit constructor:

from wit import Wit
client = Wit(access_token=access_token, logger=custom_logger)

See the logging module and logging.config docs for more information.

License

The license for pywit can be found in LICENSE file in the root directory of this source tree.

Terms of Use

Our terms of use can be found at https://opensource.facebook.com/legal/terms.

Privacy Policy

Our privacy policy can be found at https://opensource.facebook.com/legal/privacy.

GitHub Issues· 20 open

View all on GitHub
  • #167

    Support tag parameter in message() method

    Updated Apr 9, 2025
  • #2

    Add more api functions

    help wantedUpdated Sep 14, 2024
  • #176

    [Question] Account name

    Updated Oct 31, 2023
  • #172

    module 'urllib' has no attribute 'quote_plus'

    Updated Mar 9, 2023
  • #171

    *question*What is the difference between trait and intent? more detail

    Updated Feb 22, 2023
  • #165

    WitError: Wit responded with status: 400 (Bad Request)

    Updated Feb 24, 2022
  • #164

    PyPi Package Update

    Updated Dec 10, 2021
  • #24

    Implement Travis Build and test cases

    help wantedUpdated May 26, 2021
  • #152

    Request for getting alternative matches based on confidence for STT

    Updated Apr 6, 2021
  • #151

    Problem with speech recognition

    Updated Apr 1, 2021

Highlights

  • •message - the Wit message API
  • •speech - the Wit speech API
  • •interactive - starts an interactive conversation with your bot
  • •access_token - the access token of your Wit instance
  • •msg - the text you want Wit.ai to extract the information from
  • •audio_file - a file handler opened in binary mode
  • •headers - (optional) the dict of headers (e.g. "Content-Type")

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言