[Python] synthesizer in windows sounds much better than in linux (python and pyttsx3)

Discussão em 'Python' iniciado por Stack, Setembro 15, 2024.

  1. Stack

    Stack Membro Participativo

    I've made a simple text_to_speech function in python based on pyttsx3 library (in polish language).

    import pyttsx3 as tts

    engine = tts.init()
    engine.setProperty('rate', 130)
    engine.setProperty('voice', 'polish')

    def text_to_speech(text):
    engine.say(text)
    engine.runAndWait()


    When I run this on windows the voice is tolerable, but in linux sounds teribble (windows 10 and ubuntu 18.04, pyttsx==2.9 on both machines).

    I've also made for loop to print all available voices:

    voices = engine.getProperty('voices')

    for voice in voices:
    print("Voice:")
    print("ID: %s" %voice.id)
    print("Name: %s" %voice.name)
    print("Age: %s" %voice.age)
    print("Gender: %s" %voice.gender)
    print("Languages Known: %s" %voice.languages)


    Output in windows:

    Voice: ID: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_PL-PL_PAULINA_11.0 Name: Microsoft Paulina Desktop - Polish Age: None Gender: None Languages Known: [] Voice: ID: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0 Name: Microsoft Zira Desktop - English (United States) Age: None Gender: None Languages Known: []


    Output in linux:

    Voice:
    ID: english-us
    Name: english-us
    Age: None
    Gender: male
    Languages Known: \[b'\\x02en-us'\]

    Voice:
    ID: polish
    Name: polish
    Age: None
    Gender: male
    Languages Known: \[b'\\x05pl'\]

    Voice:
    ID: brazil
    Name: brazil
    Age: None
    Gender: male
    Languages Known: \[b'\\x05pt-br'\]


    and a lot of other languages
    (...)


    Is there a way to install other polish voices on linux version of pyttsx3 (or maybe other library)?

    Continue reading...

Compartilhe esta Página