0%

This fun, hands-on book will take your basic Python skills to the next level as you build voice-controlled apps to use in your daily life. Starting with a Python refresher and an introduction to speech-recognition/text-to-speech functionalities, you’ll soon ease into more advanced topics, like making your own modules and building working voice-controlled apps.

Each chapter scaffolds multiple projects that allow you to see real results from your code at a manageable pace, while end-of-chapter exercises strengthen your understanding of new concepts. You’ll design interactive games, like Connect Four and Tic-Tac-Toe, and create intelligent computer opponents that talk and take commands; you’ll make a real-time language translator, and create voice-activated financial-market apps that track the stocks or cryptocurrencies you are interested in. Finally, you’ll load all of these features into the ultimate virtual personal assistant – a conversational VPA that tells jokes, reads the news, and gives you hands-free control of your email, browser, music player, desktop files, and more.

Along the way, you’ll learn how to:

•Build Python modules, implement animations, and integrate live data into an app
•Use web-scraping skills for voice-controlling podcasts, videos, and web searches
•Fine-tune the speech recognition to accept a variety of input
•Associate regular tasks like opening files and accessing the web with speech commands
•Integrate functionality from other programs into a single VPA with computational knowledge engines to answer almost any question

Packed with cross-platform code examples to download, practice activities and exercises, and explainer images, you’ll quickly become proficient in Python coding in general and speech recognition/text to speech in particular.

Table of Contents

  1. Title Page
  2. Copyright
  3. Dedication
  4. About the Author
  5. ACKNOWLEDGMENTS
  6. Introduction
    1. About This Book
    2. What’s in This Book?
  7. Part I: Getting Started
    1. Chapter 1: Setting Up Python, Anaconda, and Spyder
    2. Introducing Anaconda and Spyder
    3. Installing Anaconda and Spyder
    4. Install Anaconda and Spyder in Windows
    5. Install Anaconda and Spyder in macOS
    6. Install Anaconda and Spyder in Linux
    7. Using Spyder
    8. Write Python in Spyder
    9. Inspect Code in Spyder
    10. Understanding Coding in Python
    11. Python Syntax
    12. Basic Operations in Python
    13. Summary
    14. End-of-Chapter Exercises
    15. Chapter 2: Python Refresher
    16. Variables and Values
    17. Strings
    18. Floats
    19. Integers
    20. Bools
    21. Convert Variable Types
    22. Rules for Variable Names
    23. Loops and Conditional Execution
    24. Conditional Execution
    25. Loops
    26. Loops in Loops
    27. Loop Commands
    28. Strings
    29. String Indexing
    30. String Slicing
    31. String Methods
    32. Lists
    33. Create a List
    34. Access Elements in a List
    35. Use a List of Lists
    36. Add or Multiply Lists
    37. List Methods
    38. Use Built-in Functions with Lists
    39. list()
    40. Dictionaries
    41. Access Values in a Dictionary
    42. Use Dictionary Methods
    43. How to Use Dictionaries
    44. Switch Keys and Values
    45. Combine Two Dictionaries
    46. Tuples
    47. Functions
    48. Use Built-in Python Functions
    49. Define Your Own Functions
    50. Modules
    51. Import Modules
    52. Create Your Own Modules
    53. Use Third-Party Modules
    54. Create a Virtual Environment
    55. Activate the Virtual Environment in Windows
    56. Set Up Spyder in the Virtual Environment in Windows
    57. Summary
    58. End-of-Chapter Exercises
  8. Part II: Learning to Talk
    1. Chapter 3: Speech Recognition
    2. Install the SpeechRecognition Module
    3. In Windows
    4. In Mac or Linux
    5. Test and Fine-Tune SpeechRecognition
    6. Import SpeechRecognition
    7. Test SpeechRecognition
    8. Fine-Tune the Speech Recognition Feature
    9. Perform a Voice-Controlled Web Search
    10. Use the webbrowser Module
    11. Add Voice Control
    12. Perform a Google Search
    13. Open Files
    14. Use the os and pathlib Modules to Access and Open Files
    15. Open Files via Voice Control
    16. Create and Import a Local Module
    17. Create the Local Module mysr
    18. Import mysr
    19. Summary
    20. End-of-Chapter Exercises
    21. Chapter 4: Make Python Talk
    22. Install the Text-to-Speech Module
    23. Setup
    24. Test Your Text-to-Speech Module
    25. Repeat After Me
    26. Customize the Speech
    27. Retrieve Default Settings in the pyttsx3 Module in Windows
    28. Adjust Speech Properties in the pyttsx3 Module in Windows
    29. Customize the gTTS Module in Mac or Linux
    30. Build the Local mysay Module
    31. Create mysay
    32. Import mysay
    33. Build a Voice-Controlled Calculator
    34. Read a File Aloud
    35. Summary
    36. End-of-Chapter Exercises
    37. Chapter 5: Speaking Applications
    38. Create Your Self-Made Local Python Package
    39. What’s a Python Package?
    40. Create Your Own Python Package
    41. Test Your Package
    42. More on Python Packages
    43. Interactive Guess the Number Game
    44. Speaking Newscast
    45. Scrape the News Summary
    46. Add the Text-to-Speech Features
    47. Voice-Controlled Wikipedia
    48. Access Wikipedia
    49. Add Speech Recognition and Text to Speech
    50. Voice-Activated Music Player
    51. Traverse Files in a Folder
    52. Python, Play Selena Gomez
    53. Python, Play a Country Song
    54. Summary
    55. End-of-Chapter Exercises
    56. Chapter 6: Web Scraping Podcasts, Radios, and Videos
    57. A Primer on Web Scraping
    58. What Is HTML?
    59. Extract Information with Beautiful Soup
    60. Scrape Live Web Pages
    61. Voice-Activated Podcasts
    62. Extract and Play Podcasts
    63. Voice-Activate Podcasts
    64. Voice-Activated Radio Player
    65. Install the selenium Module
    66. Control Web Pages
    67. Voice-Activate Live Radio
    68. Voice-Activated Videos
    69. Summary
    70. End-of-Chapter Exercises
    71. Chapter 7: Building a Virtual Personal Assistant
    72. An Overview of Your VPA
    73. Download VPA Files
    74. Install the arrow Module
    75. Manage the Standby Mode
    76. Create the Local Module mywakeup
    77. Set Some Responses
    78. Ask Your VPA to Set a Timer
    79. Tell the Time with Python
    80. Build a Timer
    81. Create the mytimer Module
    82. Set the Timer
    83. Ask Your VPA to Set an Alarm Clock
    84. Build an Alarm Clock
    85. Create the Alarm Clock Module
    86. Set an Alarm
    87. Ask Your VPA to Tell a Joke
    88. Create Your Joke List
    89. Create a Joke Module
    90. Tell a Joke
    91. Send Hands-Free Email
    92. Send Email with Written Commands
    93. Create the Email Module
    94. Add the Email Functionality
    95. Summary
    96. End-of-Chapter Exercises
    97. Chapter 8: Know-It-All VPA
    98. Get Answers from WolframAlpha
    99. Apply for an API Key
    100. Retrieve Information
    101. Explore Different Areas of Knowledge
    102. Add a Know-It-All Functionality to Your VPA
    103. What WolframAlpha Cannot Answer
    104. Create the myknowall Module
    105. A VPA That Can Answer (Almost) Any Question for You
    106. Summary
  9. Part III: Interactive Games
    1. Chapter 9: Graphics and Animation with the turtle Module
    2. Basic Commands
    3. Create a turtle Screen
    4. Create Movements
    5. Basic Shapes
    6. Use the dot() Function
    7. Draw Your Own Shapes
    8. Draw Grid Lines
    9. Animation
    10. How Animation Works
    11. Use Multiple Turtles
    12. Summary
    13. End-of-Chapter Exercises
    14. Chapter 10: Tic-Tac-Toe
    15. Game Rules
    16. Draw the Game Board
    17. Create the Game Pieces
    18. How Mouse Clicks Work in turtle
    19. Convert Mouse Clicks to Cell Numbers
    20. Place Game Pieces
    21. Determine Valid Moves, Wins, and Ties
    22. Voice-Controlled Version
    23. Summary
    24. End-of-Chapter Exercises
    25. Chapter 11: Connect Four
    26. Game Rules
    27. Draw the Game Board
    28. The Mouse-Click Version
    29. Drop a Disc
    30. Animate the Falling Discs
    31. Determine Valid Moves, Wins, and Ties
    32. The Voice-Controlled Version
    33. Summary
    34. End-of-Chapter Exercises
    35. Chapter 12: Guess-the-Word Game
    36. Game Rules
    37. Draw the Game Board
    38. The Text Version
    39. Load the Coins
    40. Guess the Letters
    41. Determine Valid Guesses, Wins, and Losses
    42. The Voice-Controlled Version
    43. Summary
    44. End-of-Chapter Exercises
    45. Chapter 13: Smart Games: Adding Intelligence
    46. The Think-Three-Steps-Ahead Strategy
    47. Think One Step Ahead
    48. Think Two Steps Ahead
    49. Implement the Think-Two-Steps-Ahead Strategy
    50. Think Three Steps Ahead
    51. The Machine-Learning Strategy
    52. Create a Dataset of Simulated Games
    53. Apply the Data
    54. Test the Effectiveness of the Two Strategies
    55. The Think-Three-Steps-Ahead Strategy
    56. The Machine-Learning Strategy
    57. Why Doesn’t the Machine-Learning Strategy Work Well in Connect Four?
    58. Voice-Controlled Intelligent Connect Four Games
    59. A Voice-Controlled Game That Thinks Ahead
    60. A Voice-Controlled Game Using Machine Learning
    61. Summary
    62. End-of-Chapter Exercises
  10. Part IV: Going Further
    1. Chapter 14: Financial Applications
    2. Python, What’s the Facebook Stock Price?
    3. Obtain the Latest Stock Price
    4. Find Ticker Symbols
    5. Retrieve Stock Prices via Voice
    6. Voice-Controlled Data Visualization
    7. Create Stock Price Plots
    8. Create Candlestick Charts
    9. Add Voice Control
    10. Voice-Controlled Stock Report
    11. Analyze Recent Stock Performance and Risk
    12. Add Voice Control
    13. Summary
    14. End-of-Chapter Exercises
    15. Chapter 15: Stock Market Watch
    16. Bitcoin Watch
    17. How to Read JSON Data
    18. A Graphical Bitcoin Watch
    19. A Talking Bitcoin Watch
    20. A Talking Stock Market Watch
    21. Apply the Method to Other Financial Markets
    22. Summary
    23. End-of-Chapter Exercises
    24. Chapter 16: Use World Languages
    25. Text to Speech in Other Languages
    26. Install Modules
    27. Convert Text to Speech in Spanish
    28. Support Text to Speech in Other Languages
    29. Convert Text to Speech in World Languages
    30. Speech Recognition in Major World Languages
    31. A Talking Wikipedia
    32. Create Your Own Voice Translator
    33. A Text-Based Translator
    34. A Voice-Based Translator
    35. Summary
    36. Chapter 17: Ultimate Virtual Personal Assistant
    37. An Overview of the Final VPA
    38. The Chatting Functionality
    39. The Music Functionality
    40. Create a Music Module
    41. Activate the Music Functionality
    42. The News Brief Module
    43. Create a News Module
    44. Activate the News Functionality
    45. The Live Radio Module
    46. Create a Radio Module
    47. Activate the Radio Functionality
    48. The Tic-Tac-Toe Module
    49. Create a Tic-Tac-Toe Module
    50. Activate Tic-Tac-Toe
    51. The Connect Four Module
    52. Create a Connect Four Module
    53. Activate Connect Four
    54. The Stock Price Module
    55. Create a Stock Market–Tracking Module
    56. Activate the Stock Market–Tracking Functionalities
    57. The Voice Translator Module
    58. Create a Translator Module
    59. Activate the Voice Translator
    60. Summary
  11. Appendix A: Install Modules to Play Audio Files
    1. Install the playsound Module
    2. Windows
    3. Mac
    4. Linux
    5. Install the pydub Module
    6. Install the pygame Module
    7. Windows
    8. Mac
    9. Linux
    10. Install the vlc Module
    11. Sample Scripts to Test the Four Modules
    12. The playsound Module
    13. The pydub Module
    14. The pygame Module
    15. The vlc Module
  12. Appendix B: Suggested Answers to End-of-Chapter Exercises
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 9
    9. Chapter 10
    10. Chapter 11
    11. Chapter 12
    12. Chapter 13
    13. Chapter 14
    14. Chapter 15
  13. Index
3.144.17.45