Skip to main content

Overview

Performs speech recognition using the Microsoft Bing Speech API. This is a legacy API that has been deprecated in favor of Azure Speech Services.
Deprecated: Microsoft Bing Speech API is deprecated. Microsoft recommends migrating to Azure Speech Services instead.

Method Signature

recognize_bing(
    audio_data: AudioData,
    key: str,
    language: str = "en-US",
    show_all: bool = False
) -> str | dict

Parameters

audio_data
AudioData
required
The audio data to recognize. Must be an AudioData instance.
key
str
required
Microsoft Bing Speech API key (32-character lowercase hexadecimal string).
language
str
default:"en-US"
Recognition language as a BCP-47 language tag (e.g., "en-US", "fr-FR", "de-DE").
show_all
bool
default:"False"
If True, returns the raw API response as a JSON dictionary. If False, returns only the transcription text.

Returns

transcript
str
The recognized text when show_all=False
response
dict
When show_all=True, returns the raw API response

Exceptions

UnknownValueError
Exception
Raised when the speech is unintelligible
RequestError
Exception
Raised when:
  • The API request fails
  • The API key is invalid
  • There is no internet connection

Migration to Azure Speech

Recommended: Use recognize_azure() instead:
import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone() as source:
    audio = r.listen(source)

# Old (deprecated):
# text = r.recognize_bing(audio, key=BING_KEY)

# New (recommended):
text, confidence = r.recognize_azure(
    audio,
    key=AZURE_KEY,
    location="westus"
)
print(text)
See recognize_azure() for complete documentation.

Notes

  • This API is deprecated and may stop working at any time
  • Migrate to Azure Speech Services for continued support
  • Access tokens are cached for 10 minutes
  • Audio is converted to 16 kHz, 16-bit samples