0

I have a table which contains HTML content to show it on Web Page.

I am trying to convert that content into text to speech after extracting plain text from it. But When I hear that converted content, there is no pause in it and voice is very continuous.

How can i maintain pauses and other things while doing Text to speech.

Example

Content in Browser

Python Code for TTS

    @app.route('/convert', methods=['POST'])
    def convert():
        if request.method=='POST' or request.method=='GET':
            area = request.form['text']
           
            parsed =BeautifulSoup(area).get_text()
            print("******************",area)
            from gtts import gTTS 
              
            # Language in which you want to convert 
            language = 'en'
              
           
            myobj = gTTS(text=parsed, lang=language, slow=False) 
              
            # Saving the converted audio in a mp3 file named 
            # welcome  
            
            import uuid
            file= str(uuid.uuid4())
            myobj.save(file+'.mp3') 
            
            return parsed
adnan
  • 504
  • 1
  • 4
  • 21

1 Answers1

0

Converting that to plain text removes the semantic info in the HTML - you'll get "1. Sustained Attention 2. Selective Attention...". You may try doing addition parsing/formatting using gtts functionality, or consider converting to SSML and using a different API (like Amazon Polly or espeak) which supports SSML.

Luke
  • 919
  • 5
  • 8