Python Forum
How can I send a .mp3 to play through my mic? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How can I send a .mp3 to play through my mic? (/thread-17272.html)

Pages: 1 2 3


Is this possible to make in Python? - ejected - Apr-04-2019

Is it possible to make a text to speech program that outputs the speech through my mic? So I can use it over Discord/TeamSpeak/Game voice chat/ect

I would assume yes but can someone very briefly point me in the right direction?

Which modules should I use?

Which functions?


RE: Is this possible to make in Python? - Larz60+ - Apr-04-2019

There are already packages that do this.
One of the more popular is gTTs: https://github.com/pndurette/gTTS
documentation here: https://gtts.readthedocs.io/en/latest/
The short side of this package is that it relies on Google and therefore needs an internet connection to run.

This can be installed with:
pip install gTTS
An alternative, that does not rely on Google is pyttsx3
homepage: https://github.com/nateshmbhat/pyttsx3
documentation here: https://pyttsx3.readthedocs.io/en/latest/

This can be installed with:
pip install pyttsx3



RE: Is this possible to make in Python? - ejected - Apr-04-2019

(Apr-04-2019, 02:07 AM)Larz60+ Wrote: There are already packages that do this.
One of the more popular is gTTs: https://github.com/pndurette/gTTS
documentation here: https://gtts.readthedocs.io/en/latest/
The short side of this package is that it relies on Google and therefore needs an internet connection to run.

This can be installed with:
pip install gTTS
An alternative, that does not rely on Google is pyttsx3
homepage: https://github.com/nateshmbhat/pyttsx3
documentation here: https://pyttsx3.readthedocs.io/en/latest/

This can be installed with:
pip install pyttsx3

Tysm, how do I get either one to work through my mic though? I don't want to just hear the text to speech myself, I want it to output to my recording device on my computer so that I can use it on voice communication stuff. Like TeamSpeak/Discord/ect

Is that possible? If so, how? Which function on either of those do I use? I can't find anything to do that.


RE: Is this possible to make in Python? - Larz60+ - Apr-04-2019

for that, you need speech to text
here are packages available: https://pypi.org/search/?q=speech+to+text
and then use text to speech to save mp3
Or if you don't need the text at all (as you stated you did
Quote:Is it possible to make a text to speech
)
you can record directly from mic, one of these: https://pypi.org/search/?q=microphone


RE: Is this possible to make in Python? - ejected - Apr-04-2019

(Apr-04-2019, 02:53 AM)Larz60+ Wrote: for that, you need speech to text
here are packages available: https://pypi.org/search/?q=speech+to+text
and then use text to speech to save mp3
Or if you don't need the text at all (as you stated you did
Quote:Is it possible to make a text to speech
)
you can record directly from mic, one of these: https://pypi.org/search/?q=microphone

Tysm again


How can I send a .mp3 to play through my mic? - ejected - Apr-04-2019

This is the code I have so far:

How can I make this .mp3 play through my mic? (so that people on Discord/TeamSpeak/Voice Chat can hear it)

from gtts import gTTS

t2s = gTTS(text="Hello this is the text to play", lang='en')
t2s.save("voice1.mp3")
I assume I would need a virtual audio cable to do this? I have VB Audio Cable installed. I don't know how to output the .mp3 into the recording device though. How do I do that in Python?


RE: How can I send a .mp3 to play through my mic? - Larz60+ - Apr-04-2019

Do not start new threads on a subject already started, it's against forum rules.
Merged with old thread


RE: How can I send a .mp3 to play through my mic? - ejected - Apr-04-2019

Sorry. Thought it would be easier to set this one to solved and ask the other question in a separate clear thread so that all these replies don't confuse people.

All I need to do is change the output device that Python plays the sound in. I have a VB audio cable. How do I change the output audio device that python plays to?


RE: How can I send a .mp3 to play through my mic? - Larz60+ - Apr-04-2019

Quote:Sorry. Thought it would be easier to set this one to solved and ask the other question in a separate clear thread
Not a problem, we are here to answer questions, a never ending process.
Which package did you choose to use?
Is the output an mp3 file?


RE: How can I send a .mp3 to play through my mic? - ejected - Apr-04-2019

(Apr-04-2019, 07:41 PM)Larz60+ Wrote:
Quote:Sorry. Thought it would be easier to set this one to solved and ask the other question in a separate clear thread
Not a problem, we are here to answer questions, a never ending process.
Which package did you choose to use?
Is the output an mp3 file?

gTTs

Yes it's a .mp3 file

All I need to do is change the output device of the sound that the python script plays. I'm using VB audio cable. So all I need to do is change the output of the sound to this:

[Image: AX2YZWH.png]