Create a Python Quote Player

Posted by : on

Category : Deep_Learning

Introduction

This article describes how I come to see the need to create an executable to play my favorite quotes and how such a simple app can be created using Python3.

For more details: Please visit Creating audio from text

Why do we need an app ?

So far, in this journey, I have collected several famous quotes. However, they exist as string in a text file in isolation. I prefer to have them read out loud to me as a means to keep my memory fresh.

I thought mere conversion of text to speech via Tacotron2 and WaveGlow would be sufficient. After all, the text has come to life. Unfortunately, reality has proved to me that challenges remain in my learning. The next challenges are to overcome the inertia and inconvenience. Currently, I play an audio clip while I read the quote in its text file side by side.

This need leads me to build an app on python and compile it as an executable on Windows 10. This way those without Python or its library can also enjoy the learning of their favorite quotes with ease.

Pyinstaller works on other OS platforms such as Linux and MacOS. Windows 10 is selected purely because my laptop runs on Windows 10.

Software and Hardware Prerequisites

  • pyinstaller 4.2

Methods

The steps are quite straightforward. Having that said, I would pay close attention to:

  • source code should be neat, tidy and bug-free;
  • any input files to the app (such as audio clips / wav files and quotes/ text file should be placed under a single directory;
  • relative path should always be used; file structure should be kept identical to the source. This ensures the program / executable could collect / find the required input data.

Pyinstaller freezes Python packages to build an executable inside the dist folder. However, the relative path used in the source code does not take the dist folder into account. Thus, this causes the program to exit prematurely. One solution is to move the executable (highlighted in a blue rectangle) to the root folder so that the relative path points to the correct data source.

Picture description

Results

Here is a screenshot.

Picture description

Here is a short demo.

Enjoy and Happy learning. Please feel free to send me your favorite quotes or other suggestions.

About

Hello, My name is Wilson Fok. I love to extract useful insights and knowledge from big data. Constructive feedback and insightful comments are very welcome!