kandi background
Explore Kits

speech_recognition | Speech recognition module for Python | Speech library

 by   Uberi Python Version: 3.8.1 License: Non-SPDX

 by   Uberi Python Version: 3.8.1 License: Non-SPDX

Download this library from

kandi X-RAY | speech_recognition Summary

speech_recognition is a Python library typically used in Artificial Intelligence, Speech applications. speech_recognition has no bugs, it has no vulnerabilities, it has build file available and it has medium support. However speech_recognition has a Non-SPDX License. You can download it from GitHub.
Speech recognition module for Python, supporting several engines and APIs, online and offline.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • speech_recognition has a medium active ecosystem.
  • It has 5813 star(s) with 1979 fork(s). There are 284 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 210 open issues and 277 have been closed. On average issues are closed in 89 days. There are 24 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of speech_recognition is 3.8.1
speech_recognition Support
Best in #Speech
Average in #Speech
speech_recognition Support
Best in #Speech
Average in #Speech

quality kandi Quality

  • speech_recognition has no bugs reported.
speech_recognition Quality
Best in #Speech
Average in #Speech
speech_recognition Quality
Best in #Speech
Average in #Speech

securitySecurity

  • speech_recognition has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
speech_recognition Security
Best in #Speech
Average in #Speech
speech_recognition Security
Best in #Speech
Average in #Speech

license License

  • speech_recognition has a Non-SPDX License.
  • Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
speech_recognition License
Best in #Speech
Average in #Speech
speech_recognition License
Best in #Speech
Average in #Speech

buildReuse

  • speech_recognition releases are available to install and integrate.
  • Build file is available. You can build the component from source.
speech_recognition Reuse
Best in #Speech
Average in #Speech
speech_recognition Reuse
Best in #Speech
Average in #Speech
Top functions reviewed by kandi - BETA

kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here

Get all kandi verified functions for this library.

Get all kandi verified functions for this library.

speech_recognition Key Features

Speech recognition module for Python, supporting several engines and APIs, online and offline.

speech_recognition Examples and Code Snippets

See all related Code Snippets

Speech Recognition(IBM) username and password

copy iconCopydownload iconDownload
def getAuthTokens(api_key):
    url     = "https://iam.cloud.ibm.com/identity/token"
    headers = { "Content-Type" : "application/x-www-form-urlencoded" }
    data    = "apikey=" + api_key + "&grant_type=urn:ibm:params:oauth:grant-type:apikey"
    response  = requests.post( url, headers=headers, data=data )
    return response.json()

Find A value in list , if there are multiple value print all the values else print the corresponding values from another list

copy iconCopydownload iconDownload
Keyword = ['Dog', 'Cat', 'White Cat', 'Lion', 'Black Cat']
Definition = ['Mans Best Friend', 'The cat is a domestic species of a small carnivorous mammal', 'White  cats are cute', 'Lions are Carnivores Wild Animal', 'Black Cats are Black in color']

def take_cmd(cmd):
    multiple_val=[]
    if cmd in Keyword:
        for i,j in enumerate(Keyword):
            if cmd in j:
                multiple_val.append((i,j))
        if len(multiple_val)>1:
            i_removed=[j for i in multiple_val for j in i if type(j)!=int]
            print(f"We have found multiple keywords : {i_removed}")
        else:
            print(Definition[Keyword.index(cmd)])
    else:
        print("There are no Matching Keywords")

Wikipedia Library shows error if input not given exactly to the name of a page of wikipedia

copy iconCopydownload iconDownload
  >>> from difflib import get_close_matches
  >>> import pywikibot
  >>> site = pywikibot.Site('wikipedia:en')  # create a Site object
  >>> title = 'National Defence Academy'
  >>> gen = site.search('intitle:' + title, total=10, namespaces=0)
  >>> titles = [page.title() for page in gen]  # list of strings required
  >>> result = get_close_matches('National Defence Academy', titles)
  >>> found = pywikibot.Page(site, result[0])
  >>> found.text[:100]
  >>> from difflib import get_close_matches
  >>> import pywikibot
  >>> site = pywikibot.Site('wikipedia:en')  # create a Site object
  >>> title = 'National Defence Academy'
  >>> gen = site.search('intitle:' + title, total=10, namespaces=0)
  >>> titles = [page.title() for page in gen]  # list of strings required
  >>> result = get_close_matches('National Defence Academy', titles)
  >>> found = pywikibot.Page(site, result[0])
  >>> found.text[:100]

Error when creating jarvis ai, object is not callable, etc

copy iconCopydownload iconDownload
def takeCommand():
r = speech_recognition.Recognizer()
with speech_recognition.Microphone() as source:
    speech_recognition.Recognizer().adjust_for_ambient_noise(source, duration=0.2)
    print("Listening...")
    audio = r.listen(source)

    try:
        query = r.recognize_google(audio, language='en-in')
        print(f"user said:{query}\n")

    except Exception as e:
        return "None"
    return query
engine = pyttsx3.init("sapi5")
voices = engine.getProperty("voices")
engine.setProperty("voice", voices[0].id)
engine.setProperty("rate", 150)


def speak(audio):
    engine.say(audio)
    engine.runAndWait()


def takeCommand():
    r = speech_recognition.Recognizer()
    with speech_recognition.Microphone() as source:
        print("Listening...")
        r.pause_threshold = 4
        r.energy_threshold = 300
        audio = r.listen(source, 0, 4)

    try:
        print("Understanding...")
        query = r.recognize_google(audio, language='en-us')
        print(f"You said: {query}\n")
    except Exception as e:
        print("Say that again")
        return "None"
    return query

def searchGoogle(query):
    import wikipedia as googleScrap
    speak("This is what I found")
    try:
        pywhatkit.search(query)
        result = googleScrap.summary(query, 1)
        speak(result)

    except:
        speak("Did not find anything about that, sorry")


def searchYoutube(query):
    web = "https://www.youtube.com/results?search_query=" + query
    webbrowser.open(web)
    pywhatkit.playonyt(query)
    speak("Done, Sir")


def searchWikipedia(query):
    results = wikipedia.summary(query,sentences=2)
    speak("According to wikipedia..")
    print(results)
    speak(results)


# Starting...............................................................................................................
if __name__ == "__main__":
    while True:
        query = takeCommand().lower()
        if "wake up David" in query:
            hour = int(datetime.datetime.now().hour)
            if 0 <= hour <= 12:
                speak("Good Morning sir, how are you?")
            elif 12 < hour <= 18:
                speak("Good Afternoon sir, how are you?")

            else:
                speak("Good Evening sir, how are you?")

        while True:
            query = takeCommand().lower()
            if "go to sleep david" in query:
                speak("Ok, See you, Remember if you need anything just say, wake up david")
                break

            elif "I'm good how are you" in query:
                speak("I am also good, how may I help you today?")

            elif "thank you" in query:
                speak("You are welcome sir")

            elif "wikipedia" in query:
                speak("Searching from wikipedia....")
                query = query.replace("wikipedia", "")
                query = query.replace("search wikipedia", "")
                query = query.replace("jarvis", "")
                searchWikipedia(query)

            elif "youtube" in query:
                speak("This is what I found for your search!")
                query = query.replace("youtube search", "")
                query = query.replace("youtube", "")
                query = query.replace("jarvis", "")
                searchYoutube(query)
            
            elif "google" in query:
                query = query.replace("david", "")
                query = query.replace("google search", "")
                query = query.replace("google", "")
                searchGoogle(query)
def takeCommand():
r = speech_recognition.Recognizer()
with speech_recognition.Microphone() as source:
    speech_recognition.Recognizer().adjust_for_ambient_noise(source, duration=0.2)
    print("Listening...")
    audio = r.listen(source)

    try:
        query = r.recognize_google(audio, language='en-in')
        print(f"user said:{query}\n")

    except Exception as e:
        return "None"
    return query
engine = pyttsx3.init("sapi5")
voices = engine.getProperty("voices")
engine.setProperty("voice", voices[0].id)
engine.setProperty("rate", 150)


def speak(audio):
    engine.say(audio)
    engine.runAndWait()


def takeCommand():
    r = speech_recognition.Recognizer()
    with speech_recognition.Microphone() as source:
        print("Listening...")
        r.pause_threshold = 4
        r.energy_threshold = 300
        audio = r.listen(source, 0, 4)

    try:
        print("Understanding...")
        query = r.recognize_google(audio, language='en-us')
        print(f"You said: {query}\n")
    except Exception as e:
        print("Say that again")
        return "None"
    return query

def searchGoogle(query):
    import wikipedia as googleScrap
    speak("This is what I found")
    try:
        pywhatkit.search(query)
        result = googleScrap.summary(query, 1)
        speak(result)

    except:
        speak("Did not find anything about that, sorry")


def searchYoutube(query):
    web = "https://www.youtube.com/results?search_query=" + query
    webbrowser.open(web)
    pywhatkit.playonyt(query)
    speak("Done, Sir")


def searchWikipedia(query):
    results = wikipedia.summary(query,sentences=2)
    speak("According to wikipedia..")
    print(results)
    speak(results)


# Starting...............................................................................................................
if __name__ == "__main__":
    while True:
        query = takeCommand().lower()
        if "wake up David" in query:
            hour = int(datetime.datetime.now().hour)
            if 0 <= hour <= 12:
                speak("Good Morning sir, how are you?")
            elif 12 < hour <= 18:
                speak("Good Afternoon sir, how are you?")

            else:
                speak("Good Evening sir, how are you?")

        while True:
            query = takeCommand().lower()
            if "go to sleep david" in query:
                speak("Ok, See you, Remember if you need anything just say, wake up david")
                break

            elif "I'm good how are you" in query:
                speak("I am also good, how may I help you today?")

            elif "thank you" in query:
                speak("You are welcome sir")

            elif "wikipedia" in query:
                speak("Searching from wikipedia....")
                query = query.replace("wikipedia", "")
                query = query.replace("search wikipedia", "")
                query = query.replace("jarvis", "")
                searchWikipedia(query)

            elif "youtube" in query:
                speak("This is what I found for your search!")
                query = query.replace("youtube search", "")
                query = query.replace("youtube", "")
                query = query.replace("jarvis", "")
                searchYoutube(query)
            
            elif "google" in query:
                query = query.replace("david", "")
                query = query.replace("google search", "")
                query = query.replace("google", "")
                searchGoogle(query)

Build a voice assistant to open the application with a path in the curly bracket

copy iconCopydownload iconDownload
paths = {
    "chrome": ['open', '/Applications/Google Chrome.app'],
    "excel": ['open', '/System/Applications/Microsoft Excel.app'],
    "calculator": ['open', '/System/Applications/Calculator.app'],
}

How to open wa.me link directly on Whastapp desktop application, rather than it redirecting to web (on PC)?

copy iconCopydownload iconDownload
import subprocess

subprocess.Popen("C:\\Windows\\System32\\whatsapp.exe")
import os
os.system("program_name")
import subprocess

subprocess.Popen("C:\\Windows\\System32\\whatsapp.exe")
import os
os.system("program_name")

IndexError: tuple index out of range when I try to create an executable from a python script using auto-py-to-exe

copy iconCopydownload iconDownload
42681 INFO: PyInstaller: 4.6
42690 INFO: Python: 3.10.0
else:
    arg = None
    extended_arg = 0 
yield (i, op, arg)
extended_arg = 0

How to close all the processes one by one in a program that operates with multiprocessing by means of an 'if' validation found in one of them process?

copy iconCopydownload iconDownload
def main_process():
    conn1, conn1_3 = multiprocessing.Pipe(duplex=True)
    conn2, conn2_3 = multiprocessing.Pipe(duplex=True)
    conn1b, conn2b = multiprocessing.Pipe(duplex=True)

    #Process 1
    p1 = multiprocessing.Process(target=capture_cam, args=(conn1, conn1b, ))
    p1.start()
    #Process 2
    finish_state = multiprocessing.Event()
    p2 = multiprocessing.Process(target=audio_listening, args=(conn2, conn2b, finish_state))
    p2.start()
    #Process 3
    p3 = multiprocessing.Process(target=actions_func, args=(conn1_3 ,conn2_3 ,))
    p3.start()

    finish_state.wait()
    p1.terminate()
    p2.terminate() # Not really necessary since the process is ending by itself
    p3.terminate()

if __name__ == '__main__':
    main_process()
def audio_listening(conn2, conn2b, finish_state):
    ...
                if text.lower() == "capture":
                    catch_current_frame = True
                elif text.lower() == "Close your program":
                    # Set the finish state event:
                    finish_state.set()
                    break
def main_process():
    conn1, conn1_3 = multiprocessing.Pipe(duplex=True)
    conn2, conn2_3 = multiprocessing.Pipe(duplex=True)
    conn1b, conn2b = multiprocessing.Pipe(duplex=True)

    #Process 1
    p1 = multiprocessing.Process(target=capture_cam, args=(conn1, conn1b, ))
    p1.start()
    #Process 2
    finish_state = multiprocessing.Event()
    p2 = multiprocessing.Process(target=audio_listening, args=(conn2, conn2b, finish_state))
    p2.start()
    #Process 3
    p3 = multiprocessing.Process(target=actions_func, args=(conn1_3 ,conn2_3 ,))
    p3.start()

    finish_state.wait()
    p1.terminate()
    p2.terminate() # Not really necessary since the process is ending by itself
    p3.terminate()

if __name__ == '__main__':
    main_process()
def audio_listening(conn2, conn2b, finish_state):
    ...
                if text.lower() == "capture":
                    catch_current_frame = True
                elif text.lower() == "Close your program":
                    # Set the finish state event:
                    finish_state.set()
                    break

Local variable referenced before assignment(speech recognition python)

copy iconCopydownload iconDownload
def speaking():
    try:
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source)
            audio = r.listen(source)
            text1 = r.recognize_google(audio)
            text = text1.lower()
    except: # here its the problem
        pass
    return text # and here
def speaking():
    try:
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source)
            audio = r.listen(source)
            text1 = r.recognize_google(audio)
            text = text1.lower()
            # or you can return text here
            # and get rid of the below else block
            # return text
    except:
        # if you get an error then do nothing
        pass
        # you can return None
        return None
    else:
        # but if the try code worked then return text
        return text
def speaking():
    try:
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source)
            audio = r.listen(source)
            text1 = r.recognize_google(audio)
            text = text1.lower()
    except: # here its the problem
        pass
    return text # and here
def speaking():
    try:
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source)
            audio = r.listen(source)
            text1 = r.recognize_google(audio)
            text = text1.lower()
            # or you can return text here
            # and get rid of the below else block
            # return text
    except:
        # if you get an error then do nothing
        pass
        # you can return None
        return None
    else:
        # but if the try code worked then return text
        return text

pyQt5 execution stops when using pyttsx3 even with Threading

copy iconCopydownload iconDownload
from gtts import gTTS
from pydub import AudioSegment
import playsound
import soundfile as sf
import pyrubberband as pyrb

def speakMsg(message):

    # Write the message to mp3
    tts = gTTS(text=message, lang="en")
    tts.save("clear_msg.mp3")

    # Change the file to wav format so it can be edited
    sound = AudioSegment.from_mp3("clear_msg.mp3")
    sound.export("clear_msg.wav", format="wav")

    # Make playback faster (and pitch it down)
    data, samplerate = sf.read("clear_msg.wav")
    data_stretch = pyrb.time_stretch(data, samplerate, 1.4)
    data_shift = pyrb.pitch_shift(data_stretch, samplerate, 0)

    # Safe it as new file and play it.
    sf.write("edit_msg.wav", data_shift, samplerate, format='wav')
    playsound.playsound("edit_msg.wav")

See all related Code Snippets

Community Discussions

Trending Discussions on speech_recognition
  • Speech Recognition(IBM) username and password
  • Google speech recognition not recognizing certain words / phrases like um and er | python
  • Find A value in list , if there are multiple value print all the values else print the corresponding values from another list
  • Wikipedia Library shows error if input not given exactly to the name of a page of wikipedia
  • Error when creating jarvis ai, object is not callable, etc
  • Build a voice assistant to open the application with a path in the curly bracket
  • How to open wa.me link directly on Whastapp desktop application, rather than it redirecting to web (on PC)?
  • IndexError: tuple index out of range when I try to create an executable from a python script using auto-py-to-exe
  • No Audio with pyttsx3 Library in Python 3 (No errors)
  • How to close all the processes one by one in a program that operates with multiprocessing by means of an 'if' validation found in one of them process?
Trending Discussions on speech_recognition

QUESTION

Speech Recognition(IBM) username and password

Asked 2022-Apr-11 at 08:50

I hope to use IBM speech recognition service without - curl or ibm_watson module.
And my attempt is below:

import speech_recognition as sr
r = sr.Recognizer()
text = r.recognize_ibm(audio,username='',password='')

Even though, I have 'Service credentials' for IBM cloud - speech to text, I cannot find correct form for the function.
In the documents of recognize_ibm(), it is said that I need to enter the link_1 to find my username in XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX format.
But the link_1 is broken. Where can I find the username and password?

I also tried text = r.recognize_ibm(audio,username='apikey',password=api_key) as the previous answers link_2.

ANSWER

Answered 2022-Apr-11 at 08:50

Here are the official API docs for Speech to Text: https://cloud.ibm.com/apidocs/speech-to-text

It includes various samples and further links. You can use the IAMAuthenticator to turn an API key into an authentication token and to handle refresh tokens. If you don't want to make use of the SDK you have to deal with the IBM Cloud IAM Identity Service API on your own. The API has functions to obtain authentication / access tokens.

I often use a function like this to turn an API key into an access token:

def getAuthTokens(api_key):
    url     = "https://iam.cloud.ibm.com/identity/token"
    headers = { "Content-Type" : "application/x-www-form-urlencoded" }
    data    = "apikey=" + api_key + "&grant_type=urn:ibm:params:oauth:grant-type:apikey"
    response  = requests.post( url, headers=headers, data=data )
    return response.json()

You could

Source https://stackoverflow.com/questions/71821208

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install speech_recognition

You can download it from GitHub.
You can use speech_recognition like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Consider Popular Speech Libraries
Try Top Libraries by Uberi
Compare Speech Libraries with Highest Support
Compare Speech Libraries with Highest Quality
Compare Speech Libraries with Highest Security
Compare Speech Libraries with Permissive License
Compare Speech Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.