Python Forum
How can I send a .mp3 to play through my mic?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I send a .mp3 to play through my mic?
#1
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?
Reply
#2
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
Underscore likes this post
Reply
#3
(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.
Reply
#4
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
Reply
#5
(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
Reply
#6
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?
Reply
#7
Do not start new threads on a subject already started, it's against forum rules.
Merged with old thread
Reply
#8
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?
Reply
#9
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?
Reply
#10
Photo 
(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]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Play the next music in a list Pymax 0 1,219 Jul-28-2021, 07:27 PM
Last Post: Pymax
  how do i play an mp3 from a list gr3yali3n 3 2,155 Dec-01-2020, 08:50 AM
Last Post: Axel_Erfurt
  How to play against the computer Help_me_Please 4 4,090 Aug-29-2019, 03:37 PM
Last Post: ThomasL

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020