Coders Packet

Audio based file handling in Python

By Pusuluri Sidhartha Aravind

The project utilizes python's libraries and other packages to provide simple file handling services on txt files using audio input.


To perform the normal file handling services python is quite helpful. But by using various libraries in python it is possible to make this process more streamlined by using a completely voice-based interface without having to input any details by hand.

The different libraries used in this project are:

pyttsx3: Primarily used for performing text-to-speech conversions.

SpeechRecognition: Primarily used to for performing the speech-to-text conversion.

gtts: It is both a CLI tool and a python library with Google Translate API.


In the provided project the function system_speak(audio,language) is used for allowing the text input provided within to be put out as a voice from the system.

Further, the function audio_inp_rec(param) allows the system to take the audio input provided by the user and convert it to a useful plain string. 



1. Python 2.6 or above.

2. PyAudio as per system specification.

3.Further guide:

pip install pyttsx3

pip install SpeechRecognition

pip install gtts

googletrans: pip install googletrans



The input format is quite easy to understand as it is a common question-and-answer kind of interface making it easy even for a novice user to use.


Before performing

The above-provided image is that of the location where the code for the program lies and is also the location where any files if created by python will exist. In this case is the image prior to any creation done by python.


The above-provided image is where the first input provision is done to python. Here a file called 'trial' is used to perform the append function initially. Since there is no file named trial, python creates a file called python in the location. Upon further reading the file appended, the data in the file is printed out which is similar to the input provided to the program as well.

The image below indicates the creation of the file named 'trial.txt' as per the performed action.

After performing2nd input

The above-provided image is where the second input is provided to the program, where we use the same file 'trial.txt' to perform the actions. Here we can have provided an input "now this is the second input" to the same file. Upon requesting for a read action on the file 'trial.txt', we see that the result is the information that we have previously provided along with the new input provided implying a successful append to the text document.



The output is the successful completion of the basic file-handling services provided by the program on a file of the user's desire.

Download Complete Code


No comments yet