A
A
Alexander Kuznetsov2020-07-12 17:03:28
Python
Alexander Kuznetsov, 2020-07-12 17:03:28

How to merge two audio files in python?

It is necessary to make one out of the spirit of audio files. For example, in the first line I write "Hi" in Russian, and in the second "Hello" in English. And in the end they should be combined into one audio file. How to do it ?

from gtts import gTTS

  
import os


text= input("")
text2= input("")

language = 'zh-CN'
language2 = 'ru'


myobj=gTTS(text=text, lang=language, slow=False)
myobj.save('1.mp3')

myobj2=gTTS(text=text2, lang=language2, slow=False)
myobj2.save('2.mp3')
 


os.system("mpg321 welcome.mp3")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SirotaKazansky, 2020-07-12
@SirotaKazansky

from pydub import AudioSegment
sound1 = AudioSegment.from_mp3("/home/user/bleach.mp3")
sound2 = AudioSegment.from_mp3("/home/user/dollar.mp3")
sound3=sound1+sound2
sound3.export("/home /user/3.mp3", format="mp3")
I don't know where understanding is needed...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question