Make Python Talk: Build Apps with Voice Control and Speech Recognition [1 ed.] 9781718501560, 9781718501577, 1718501560

A project-based book that teaches beginning Python programmers how to build working, useful, and fun voice-controlled ap

1,030 183 7MB

English Pages 408 Year 2021

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
About the Author
Introduction
About This Book
What’s in This Book?
Part I: Getting Started
Chapter 1: Setting Up Python, Anaconda, and Spyder
Introducing Anaconda and Spyder
Installing Anaconda and Spyder
Install Anaconda and Spyder in Windows
Install Anaconda and Spyder in macOS
Install Anaconda and Spyder in Linux
Using Spyder
Write Python in Spyder
Inspect Code in Spyder
Understanding Coding in Python
Python Syntax
Basic Operations in Python
Summary
End-of-Chapter Exercises
Chapter 2: Python Refresher
Variables and Values
Strings
Floats
Integers
Bools
Convert Variable Types
Rules for Variable Names
Loops and Conditional Execution
Conditional Execution
Loops
Loops in Loops
Loop Commands
Strings
String Indexing
String Slicing
String Methods
Lists
Create a List
Access Elements in a List
Use a List of Lists
Add or Multiply Lists
List Methods
Use Built-in Functions with Lists
list()
Dictionaries
Access Values in a Dictionary
Use Dictionary Methods
How to Use Dictionaries
Switch Keys and Values
Combine Two Dictionaries
Tuples
Functions
Use Built-in Python Functions
Define Your Own Functions
Modules
Import Modules
Create Your Own Modules
Use Third-Party Modules
Create a Virtual Environment
Activate the Virtual Environment in Windows
Set Up Spyder in the Virtual Environment in Windows
Summary
End-of-Chapter Exercises
Part II: Learning to talk
Chapter 3: Speech Recognition
Install the SpeechRecognition Module
In Windows
In Mac or Linux
Test and Fine-Tune SpeechRecognition
Import SpeechRecognition
Test SpeechRecognition
Fine-Tune the Speech Recognition Feature
Perform a Voice-Controlled Web Search
Use the webbrowser Module
Add Voice Control
Perform a Google Search
Open Files
Use the os and pathlib Modules to Access and Open Files
Open Files via Voice Control
Create and Import a Local Module
Create the Local Module mysr
Import mysr
Summary
End-of-Chapter Exercises
Chapter 4: Make Python Talk
Install the Text-to-Speech Module
Setup
Test Your Text-to-Speech Module
Repeat After Me
Customize the Speech
Retrieve Default Settings in the pyttsx3 Module in Windows
Adjust Speech Properties in the pyttsx3 Module in Windows
Customize the gTTS Module in Mac or Linux
Build the Local mysay Module
Create mysay
Import mysay
Build a Voice-Controlled Calculator
Read a File Aloud
Summary
End-of-Chapter Exercises
Chapter 5: Speaking Applications
Create Your Self-Made Local Python Package
What’s a Python Package?
Create Your Own Python Package
Test Your Package
More on Python Packages
Interactive Guess the Number Game
Speaking Newscast
Scrape the News Summary
Add the Text-to-Speech Features
Voice-Controlled Wikipedia
Access Wikipedia
Add Speech Recognition and Text to Speech
Voice-Activated Music Player
Traverse Files in a Folder
Python, Play Selena Gomez
Python, Play a Country Song
Summary
End-of-Chapter Exercises
Chapter 6: Web Scraping Podcasts, Radios, and Videos
A Primer on Web Scraping
What Is HTML?
Extract Information with Beautiful Soup
Scrape Live Web Pages
Voice-Activated Podcasts
Extract and Play Podcasts
Voice-Activate Podcasts
Voice-Activated Radio Player
Install the selenium Module
Control Web Pages
Voice-Activate Live Radio
Voice-Activated Videos
Summary
End-of-Chapter Exercises
Chapter 7: Building a Virtual Personal Assistant
An Overview of Your VPA
Download VPA Files
Install the arrow Module
Manage the Standby Mode
Create the Local Module mywakeup
Set Some Responses
Ask Your VPA to Set a Timer
Tell the Time with Python
Build a Timer
Create the mytimer Module
Set the Timer
Ask Your VPA to Set an Alarm Clock
Build an Alarm Clock
Create the Alarm Clock Module
Set an Alarm
Ask Your VPA to Tell a Joke
Create Your Joke List
Create a Joke Module
Tell a Joke
Send Hands-Free Email
Send Email with Written Commands
Create the Email Module
Add the Email Functionality
Summary
End-of-Chapter Exercises
Chapter 8: Know-It-All VPA
Get Answers from WolframAlpha
Apply for an API Key
Retrieve Information
Explore Different Areas of Knowledge
Add a Know-It-All Functionality to Your VPA
What WolframAlpha Cannot Answer
Create the myknowall Module
A VPA That Can Answer (Almost) Any Question for You
Summary
Part III: Interactive Games
Chapter 9: Graphics and Animation with the turtle Module
Basic Commands
Create a turtle Screen
Create Movements
Basic Shapes
Use the dot() Function
Draw Your Own Shapes
Draw Grid Lines
Animation
How Animation Works
Use Multiple Turtles
Summary
End-of-Chapter Exercises
Chapter 10: Tic-Tac-Toe
Game Rules
Draw the Game Board
Create the Game Pieces
How Mouse Clicks Work in turtle
Convert Mouse Clicks to Cell Numbers
Place Game Pieces
Determine Valid Moves, Wins, and Ties
Voice-Controlled Version
Summary
End-of-Chapter Exercises
Chapter 11: Connect Four
Game Rules
Draw the Game Board
The Mouse-Click Version
Drop a Disc
Animate the Falling Discs
Determine Valid Moves, Wins, and Ties
The Voice-Controlled Version
Summary
End-of-Chapter Exercises
Chapter 12: Guess-the-Word Game
Game Rules
Draw the Game Board
The Text Version
Load the Coins
Guess the Letters
Determine Valid Guesses, Wins, and Losses
The Voice-Controlled Version
Summary
End-of-Chapter Exercises
Chapter 13: Smart Games: Adding Intelligence
The Think-Three-Steps-Ahead Strategy
Think One Step Ahead
Think Two Steps Ahead
Implement the Think-Two-Steps-Ahead Strategy
Think Three Steps Ahead
The Machine-Learning Strategy
Create a Dataset of Simulated Games
Apply the Data
Test the Effectiveness of the Two Strategies
The Think-Three-Steps-Ahead Strategy
The Machine-Learning Strategy
Why Doesn’t the Machine-Learning Strategy Work Well in Connect Four?
Voice-Controlled Intelligent Connect Four Games
A Voice-Controlled Game That Thinks Ahead
A Voice-Controlled Game Using Machine Learning
Summary
End-of-Chapter Exercises
Part IV: Going Further
Chapter 14: Financial Applications
Python, What’s the Facebook Stock Price?
Obtain the Latest Stock Price
Find Ticker Symbols
Retrieve Stock Prices via Voice
Voice-Controlled Data Visualization
Create Stock Price Plots
Create Candlestick Charts
Add Voice Control
Voice-Controlled Stock Report
Analyze Recent Stock Performance and Risk
Add Voice Control
Summary
End-of-Chapter Exercises
Chapter 15: Stock Market Watch
Bitcoin Watch
How to Read JSON Data
A Quick Introduction to the tkinter Package
A Graphical Bitcoin Watch
A Talking Bitcoin Watch
A Talking Stock Market Watch
Apply the Method to Other Financial Markets
Summary
End-of-Chapter Exercises
Chapter 16: Use World Languages
Text to Speech in Other Languages
Install Modules
Convert Text to Speech in Spanish
Support Text to Speech in Other Languages
Convert Text to Speech in World Languages
Speech Recognition in Major World Languages
A Talking Wikipedia
Create Your Own Voice Translator
A Text-Based Translator
A Voice-Based Translator
Summary
Chapter 17: Ultimate Virtual Personal Assistant
An Overview of the Final VPA
The Chatting Functionality
The Music Functionality
Create a Music Module
Activate the Music Functionality
The News Brief Module
Create a News Module
Activate the News Functionality
The Live Radio Module
Create a Radio Module
Activate the Radio Functionality
The Tic-Tac-Toe Module
Create a Tic-Tac-Toe Module
Activate Tic-Tac-Toe
The Connect Four Module
Create a Connect Four Module
Activate Connect Four
The Stock Price Module
Create a Stock Market–Tracking Module
Activate the Stock Market–Tracking Functionalities
The Voice Translator Module
Create a Translator Module
Activate the Voice Translator
Summary
Appendix A: Install Modules to Play Audio Files
Install the playsound Module
Windows
Mac
Linux
Install the pydub Module
Install the pygame Module
Windows
Mac
Linux
Install the vlc Module
Sample Scripts to Test the Four Modules
The playsound Module
The pydub Module
The pygame Module
The vlc Module
Appendix B: Suggested Answers to End-of-Chapter Exercises
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Index

Make Python Talk: Build Apps with Voice Control and Speech Recognition [1 ed.]
 9781718501560, 9781718501577, 1718501560

  • Commentary
  • Vector PDF
  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Recommend Papers