0

I'm trying to make two gtts voices, Sarah and Mary, talk to each other reading a standard script. After 2 sentences of using the same voice, they start repeating the last word until the duration of the sentence is over.

from moviepy.editor import *
import moviepy.editor as mp
from gtts import gTTS

dialog = "Mary: Mom, can we get a dog? 

\nSarah: What kind of dog do you want?

\nMary: I’m not sure. I’ve been researching different breeds and I think I like corgis.

\nSarah: Corgis? That’s a pretty popular breed. What do you like about them?

\nMary: Well, they’re small, so they won’t take up too much room. They’re also very loyal and friendly. Plus, they’re really cute!

\nSarah: That’s true. They do seem like a great breed. Have you done any research on their care and grooming needs?

\nMary: Yes, I have. They don’t need a lot of grooming, but they do need regular brushing and occasional baths. They’re also very active, so they need plenty of exercise.

\nSarah: That sounds like a lot of work. Are you sure you’re up for it?

\nMary: Yes, I am. I’m willing to put in the effort to take care of a corgi.

\nSarah: Alright, if you’re sure. Let’s look into getting a corgi then.

\nMary: Yay! Thank you, Mom!"

lines = dialog.split("\n")

combined = AudioFileClip("Z:\Programming Stuff\Music\Type_Beat__BPM105.wav").set_duration(10) #ADD INTRO MUSIC
for line in lines:
    if "Sarah:" in line:
        # Use a voice for Person 1
        res = line.split(' ', 1)[1] #Removes the first name
        tts = gTTS(text=str(res), lang='en') #Accent Changer
        tts.save("temp6.mp3")#temp save file cuz audio must mix audio clips
        combined = concatenate_audioclips([combined, AudioFileClip("temp6.mp3")])
    elif "Mary:" in line:
        # Use a voice for Person 2
        res = line.split(' ', 1)[1] #Removes the first name
        tts = gTTS(text=str(res), lang='en', tld = 'com.au') #Accent Changer
        tts.save("temp6.mp3") #temp save file cuz audio must mix audio clips
        combined = concatenate_audioclips([combined, AudioFileClip("temp6.mp3")])

combined.write_audiofile("output3.mp3") #Final File Nmae

OUTPUT: It's an audio file that outputs almost exactly the intended output, except after "They're also very loyal and friendly." it keeps repeating "plus". It also repeats at "Yes, I have. They don't need a lot of grooming, but they do need regular brushing and occasional baths." It repeats "baths" many times. It appears it just repeats after saying 2 sentences and I have no idea why.

Electro
  • 17
  • 8
  • I believe this is a case of the model confusing some words or symbols. I would suggest creating an issue tracker for this identify the error and help them improve Google's TTS. https://cloud.google.com/support/docs/issue-trackers – Nestor Ceniza Jr Jan 20 '23 at 23:14

0 Answers0