0

I want to use the google text to speech(gTTS) in my visual studio code project. I need help with: a) downloading it b)using it in VS Code c) running it in VS Code

I've been really confused on trying to use this module and other modules in VS Code.

Thanks for helping in advance, if anything is unclear leave a comment and i'll update the question!

OscarF123
  • 31
  • 2
  • 8

1 Answers1

0

If I understand your question correctly, then you just need to install the gTTS module using pip install gTTS from the terminal (to this you need to have python set to path).

Demonstration of install of gTTS in VS code

To open the terminal in VS code you can use the keyboard shortcut Ctrl + Shift + P to bring up the command pallet, where in you can type terminal and then you will see a option to open the terminal in VS code.

Opening the terminal in VS code

Then you will be able to use the module in your python files like this:

>>> from gtts import gTTS
>>> tts = gTTS('hello')
>>> tts.save('hello.mp3')

This piece will take the string and save it as a mp3 file of the gTTS voice from the text in line 2.

Demonstration of the code-example in VS code

For more information go to the official site for gTTS: https://pypi.org/project/gTTS/

For using python modules in VS code or any other editor is just the matter of installing them using the guidance on the module's website (sometimes one needs to restart the editor before one can use the module). Then to use the module one just needs to import it in the beginning og the file, that the module needs to be used.