I am learning django. I am stuck with this problem.
So basically, I have designed a form (template) in HTML that takes a text file as input and generates a voiceover of that text file. I am using espeak for it in the backend. So, when a user uploads a file, this command espeak -ven+m1 -f sample.txt where sample.txt is the name of the uploaded file should run in a new terminal window.
As you can see in the above image this is what I want to achieve.
espeak -ven+m1 -f sample.txtI want to print the above line in a new terminal window.
Here, sample.txt is the name of the text file. I want to achieve this by the python program instead of doing it manually.
As I already said I am new to django and some help will be appreciated.
Edit:
I tried to run this command
subprocess.run(['gnome-terminal', '--', f"espeak -ven+m1 -f {uploaded_file.name}"])But the output I am getting is this
There was an error creating the child process for this terminal
Failed to execute child process “espeak -ven+m1 -f sample.txt” (No such file or directory)Also please note that Run a custom command instead of my shell checkbox is untick
1 Answer
you can use this command to open a new terminal and run your command in it:
gnome-terminal -x sh -c "python3; bash"Here python3 is the command I am running, you can replace it with your command:
gnome-terminal -x sh -c "espeak -ven+m1 -f sample.txt; bash"Now to sum up everything, use this code in your python program:
from subprocess import call
call(["gnome-terminal", "-x", "sh", "-c", "espeak -ven+m1 -f sample.txt; bash"])Note: If you're using any other terminal emulator, then you must replace gnome-terminal with your emulator.
For more info, please visit this link
0