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.

sample output

As you can see in the above image this is what I want to achieve.

espeak -ven+m1 -f sample.txt

I 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.

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)

new shell output

Also please note that Run a custom command instead of my shell checkbox is untick

  • Hello. Please do not have pictures of text. Include the text in the body of the question.
    – David
    Apr 9, 2022 at 7:15
  • @David Done. Actually I put that picture to make the problem clearer. Apr 9, 2022 at 7:19
  • What you should do is use subprocess.run or similar to run gnome-terminal -x espeak ..., instead of using print() to just show the command you're running.
    – muru
    Apr 9, 2022 at 7:22
  • Terminology: with "shell", you mean a new terminal window? Perhaps you can rather have a dialog of your program print these commands in a separate window?
    – vanadium
    Apr 9, 2022 at 8:49
  • @vanadium I have made corrections. Perhaps it is clear now. Apr 9, 2022 at 10:05

1 Answer 1


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.