Build A Python Speech Assistant App

Share it with your friends Like

Thanks! Share it with your friends!

Close

In this video we will build a speech assistant app using the speech regonition library and Google’s text-to-speech API.

Download Kite free:
https://kite.com/download/?utm_medium=referral&utm_source=youtube&utm_campaign=TechGuyWeb&utm_content=speech-assistant-tutorial

Code:
https://github.com/bradtraversy/alexis_speech_assistant

๐Ÿ’– Become a Patron: Show support & get perks!
http://www.patreon.com/traversymedia

Website & Udemy Course Links:
https://www.traversymedia.com

Follow Traversy Media:
https://www.twitter.com/traversymedia
https://www.instagram.com/traversymedia
https://www.facebook.com/traversymedia

Comments

zeustherott says:

min 23:30
def alexis_speak(audio_string)
threw some errors on my setup because of pyaudio (MCI not detected)
I fixed it using pyttsx3, not generating and playing mp3, just speak from string as follows:

u need:
import pyttsx3
engine = pyttsx3.init()
u dont need:

#import os

#import random

#from gtts import gTTS

def alexis_speak(audio_string):
dont do:

#tts = gTTS(text=audio_string, lang="de")

#r = random.randint(1, 10000000)

#audio_file = "audio-" + str(r) + ".mp3"

#tts.save(audio_file)
#os.remove(audio_file)

just do:
enine.say(audio_string)

print(audio_string)

engine.runAndWait()

This fix worked for me

Preston Shotts says:

is anyone else not able to get this first installs to work? i have looked it up and haven't been able to find anything online to help me figure it out. the "venv/bin/activate" says "no such file or directory"

Everything Tacos says:

Hello, can you please explain if there is any way to do this without pip, since my pip is not working? Thanks!

Pygmalion says:

Hello, i can't install pyaudio and i have already tried installing visual studio c++ again.

here is the error code (which i literally do not have any idea what it's saying):

(venv) PS C:UsersuserDesktopCodingPythonspeech> pip install pyaudio

Collecting pyaudio

Using cached PyAudio-0.2.11.tar.gz (37 kB)

Using legacy 'setup.py install' for pyaudio, since package 'wheel' is not installed.

Installing collected packages: pyaudio

Running setup.py install for pyaudio … error

ERROR: Command errored out with exit status 1:

command: 'c:usersuserdesktopcodingpythonvenvscriptspython.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\user\AppData\Local\Temp\pip-install-h3_xztlm\pyaudio_ed19c843927e4d4a9d6303dc8a6e860a\setup.py'"'"'; __file__='"'"'C:\Users\user\AppData\Local\Temp\pip-install-h3_xztlm\pyaudio_ed19c843927e4d4a9d6303dc8a6e860a\setup.py'"'"';f = getattr(tokenize,

'"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'rn'"'"',

'"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install –record 'C:UsersuserAppDataLocalTemppip-record-5sg_cu_finstall-record.txt' –single-version-externally-managed –compile –install-headers 'c:usersuserdesktopcodingpythonvenvincludesitepython3.9pyaudio'

cwd: C:UsersuserAppDataLocalTemppip-install-h3_xztlmpyaudio_ed19c843927e4d4a9d6303dc8a6e860a

Complete output (9 lines):

running install

running build

running build_py

creating build

creating buildlib.win-amd64-3.9

copying srcpyaudio.py -> buildlib.win-amd64-3.9

running build_ext

building '_portaudio' extension

error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/

—————————————-

ERROR: Command errored out with exit status 1: 'c:usersuserdesktopcodingpythonvenvscriptspython.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\user\AppData\Local\Temp\pip-install-h3_xztlm\pyaudio_ed19c843927e4d4a9d6303dc8a6e860a\setup.py'"'"'; __file__='"'"'C:\Users\user\AppData\Local\Temp\pip-install-h3_xztlm\pyaudio_ed19c843927e4d4a9d6303dc8a6e860a\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code =

f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install –record 'C:UsersuserAppDataLocalTemppip-record-5sg_cu_finstall-record.txt' –single-version-externally-managed –compile –install-headers 'c:usersuserdesktopcodingpythonvenvincludesitepython3.9pyaudio' Check the logs for full command output.

TheGammersSimulant says:

what version of python is it?

Savvier Prow says:

can you show how to implement it in the website?

Muhammad Ali says:

Sir i am currently working on a project and i want to enable voice control system in Facebook, Instagram and WhatsApp like you say read it reads out the text for you

Ramiz Maksumic says:

Hi, great tutorial, thanks a lot Brad. I was wondering is it working with some other languages?

AbdulRahman TUF says:

Hey guys! It was of course a wonderful project, but I tried copy pasting the code from the GitHub repo and when I run it, it showed me an error of "cannot remove audio-{numbers}" file so I tried using os.unlink() instead of os.remove() and now I have a different error message that says, "The driver cannot recognize the specified command parameter." So if anyone has any ideas then they will be much appreciated. Thank you!

chekystar says:

ta gat this even with your code ๐Ÿ™

playsound.PlaysoundException:

Error 261 for command:

open audio11880527.mp3

The driver cannot recognize the specified command.

Carls Zarigata says:

Awesome video, wish you made a part 2 to explain the new code on GitHub… loved to learn to make the relation with the other file

Chiron Pugh says:

I was just wondering why mine stops running after encountering an unknown value?

STRYKER says:

A telegram channel selling your course at 15$

Write a comment

*

Area 51
Ringing

Answer