I am learning django. I am stuck with this problem.

I want to open a new terminal and execute a command in it. Here is the code that I used to do it.

run(["gnome-terminal", "--", "sh", "-c", f"espeak -ven+m1 -f {file_name.name} -w {fbh}.wav "])

I have written the above code in my views.py file. Here, {file_name.name} is the name of the text file I take as input from the user {fbh} is the name of the generated audio file.

Everything works perfectly but the problem is that the terminal opens in auto_generation directory and executes the code namely, espeak -ven+m1 -f {file_name.name} -w {fbh}.wav there but I want that it should open in media directory and execute the code there. media is a sub-directory of the auto_generation directory.

Can someone please suggest me what changes I should do to the above command so that the new terminal opens in media directory instead of auto_generation directory?

As I already said I am new to django and some help will be appreciated.

1 Answer 1

  • Django is a web framework, it is not supposed to call a GUI tool like gnome-terminal.

    Use python-espeak or call espeak directly without any shell-emulator.

  • You may include path with filename or use Python function to change directory or use as cd ...; speak with a shell command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .