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?
#19
I want the text to speech to go through my mic so that people who are in a voice channel with me will hear the text to speech.

I don't know how else to explain it... I really don't. I don't mean to sound rude or mean or condescending or whatever I understand you guys are just trying to help me, but maybe if you guys aren't native Americans translate it to your native language? Again don't mean to sound like a poopy face or whatever, but maybe that will help?

Here are some alternative explanations of what I want to do/worded a bit differently:

- play a .mp3 through my microphone (on Discord/TeamSpeak/Skype/other voice comm programs) instead of speakers.
- play a .mp3 through my VB Audio Cable (which is a different playback device I have, OTHER THEN my default one. [see this screenshot: https://i.imgur.com/R5tUECr.png)
- play .mp3 music through my microphone (on Discord/TeamSpeak/Skype/ect)
- play .mp3 to my default RECORDING DEVICE. INSTEAD OF PLAYBACK DEVICE. [ https://imgur.com/a/Phe7zE1 ]
- play .mp3 to a SPECIFIC PLAYBACK DEVICE. NOT MY DEFAULT ONE. (while not changing it to default. For example, you know how you can change your recording device on Skype/TeamSpeak/Discord ect? Like that.) [Example of another program that does this: https://i.imgur.com/IMVXRvO.png - See how you can choose a specific playback device? This is what I want to do. I want to choose a specific playback device to use instead of my default one.]

- Change the playback output device of this voice1.mp3 TO A SPECIFIC PLAYBACK DEVICE. NOT MY DEFAULT WINDOWS ONE:
from gtts import gTTS

 
t2s = gTTS(text="Hello this is the text to play", lang='en')
t2s.save("voice1.mp3")
to a device other then my default one. (again to this: https://i.imgur.com/R5tUECr.png)

- Make this play voice1.mp3 THROUGH MY RECORDING DEVICE (microphone) INSTEAD OF MY PLAYBACK DEVICE (to one of THESE: https://i.imgur.com/AO4Vx5p.png)

from gtts import gTTs
 
t2s = gTTS(text="Hello this is the text to play", lang='en')
t2s.save("voice1.mp3")
Any ONE of those methods in the explanations above is enough. I don't need all of them. Just one should work.


(Apr-05-2019, 04:35 AM)Skaperen Wrote: to inject this sound where the mic sound is going? if the latter, where is the mic sound going?

Yes. This is what I mean. The mic sound is going to any voice recording software/program/game. (For example: Skype call. ANY program that records the mic)


So I managed to get this to (maybe) work but now I'm getting this error. How do I get pygame to use that audio driver?

from gtts import gTTS
import os


t2s = gTTS(text="This text", lang='en').save("lastplayed.mp3")

from pygame import *
os.putenv('SDL_AUDIODRIVER', 'vbaudiovacwdm')
mixer.init()
mixer.music.load("lastplayed.mp3")
mixer.music.play()

while mixer.music.get_busy():
    time.Clock().tick(100)
C:\Users\Mario\PycharmProjects\N1\venv\Scripts\python.exe C:/Users/Mario/PycharmProjects/N1/venv/new.py
pygame 1.9.5
Traceback (most recent call last):
Hello from the pygame community. https://www.pygame.org/contribute.html
  File "C:/Users/Mario/PycharmProjects/N1/venv/new.py", line 9, in <module>
    mixer.init()
pygame.error: No available audio device

Process finished with exit code 1
Reply


Messages In This Thread
Is this possible to make in Python? - by ejected - Apr-04-2019, 01:23 AM
RE: How can I send a .mp3 to play through my mic? - by ejected - Apr-05-2019, 06:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Play the next music in a list Pymax 0 1,212 Jul-28-2021, 07:27 PM
Last Post: Pymax
  how do i play an mp3 from a list gr3yali3n 3 2,143 Dec-01-2020, 08:50 AM
Last Post: Axel_Erfurt
  How to play against the computer Help_me_Please 4 4,074 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