Speech2txt Instructions - selmling/Analytics-and-Data-Exploration GitHub Wiki

Running the script

  1. Create a new folder on your system (preferably on your Desktop). This is where you where you will run all the scripts from.

  2. Next, you have to add the following 4 things to the folder you just created:

    • (a) Audio File: this is the audio file that you want to process. Make sure that it is a wav file. In the screenshot below I am using a file named story.wav.

    • (b) Main Script: this is the main script that you will be running. In the screenshot below it is named wav2txt.py.

    • (c) Supplementary Script: this is the supplementary Python script that the main script will call upon. In the screenshot below it is named textgrid2csv.py.

    • (d) Praat Script: this is the supplementary Praat script that the main script will call upon. In the screenshot below it is named mark_pauses.praat.

  3. Now, open the Main Python script (wav2txt.py in this demo) in your preferred text editor (I’m using Atom in this demo). The comments in the code explicitly state what needs to be done, however, I will reiterate it over here. The following three variables need to set manually in Python script:

    • (a) audio_dir: set this variable to the file path of the new folder that you created. In order to get the file path on a system running macOS, right click on particular file or folder and simultaneously click the option button and select the option Copy "file" as Pathname. On a Windows system, right click and simultaneously click shift button and select the option "Copy as path".

    • (b) main: set this variable to the name of the audio file (story in this demo) without the .wav file extension.

    • (c) praat: set this variable to the file path of the praat script (mark _pauses.praat in this demo) mentioned earlier. Copy the file path in the exact same way you did when setting the audio_dir variable. Here is a screenshot of how the Python script should look once you are done setting the aforementioned variables:

  4. You are now finally ready to run the script. Go ahead and open the command line application on your computer. The standard application is Terminal on macOS systems and Command Prompt on Windows. Once you have the terminal opened up, navigate your way to the folder that you created back in Step 1. Here are some helpful functions that will help you navigate your computer through the command line:

    • macOS: use the cd command for changing directories and ls command for viewing all the items in the current working directory. Here is a helpful reference of terminal commands for macOS.

    • macOS: use the cd command for changing directories and dir command for viewing all the items in the current working directory. Here is a helpful reference of terminal commands for Windows.

    • Once you are in the correct working directory, run the following command:

    python3 <Main File Name>
    
    • In the demo the filename is wav2txt.py so we run the command as follows:
    python3 wav2txt.py
    
  5. After running the above command, the script might take some time to run depending on the size, quality, and contents of the audio file. Once the script has finished running, the folder should contain a file named processed_main.txt where ’main’ is the name of the audio file that was just processed.

  6. Congratulations! You have now completed the processes of converting your audio file to a formatted text file. Now, save the output file mentioned in Step 5 (processed_main.txt) at your desired location and go ahead and delete the rest of the folder if you want to (as these were just copies of the scripts and files).