Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Add Festival TTS support #2643

Merged
merged 1 commit into from
Jul 28, 2020
Merged

Add Festival TTS support #2643

merged 1 commit into from
Jul 28, 2020

Conversation

jmontane
Copy link
Contributor

Description

This PR adds Festival TTS engine suport #2640

How to test

Just install festival tts engine and voices (Catalan is a good example). And set mycroft settings:

{
    "module": "festival",
    "festival": {
      "lang": "catalan",
      "encoding": "ISO-8859-15//TRANSLIT"
    }
}

Contributor license agreement signed?

Yes, I do.

@devops-mycroft devops-mycroft added the CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) label Jul 25, 2020
@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

Copy link
Contributor

@krisgesling krisgesling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, couple more things I just noticed while testing it out.

It would also be great if you can squash the commits into a single "Add Festival TTS engine". This helps to keep the commit history of mycroft-core cleaner, making it much easier to know what each commit is related to.

If you're not familiar with git it sounds scary but, here's a nice overview of how to do it. If you run into any trouble let us know.
https://stackabuse.com/git-squash-multiple-commits-in-to-one-commit/


def execute(self, sentence, ident=None, listen=False):

encoding = self.config.get('encoding')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to set 'utf8' as the default here so that by default we don't convert the text:

encoding = self.config.get('encoding', 'utf8')

Wondering if we also need a TTS specific lang config?

Looking at Festival it seems that they use the full names of languages eg "English" so self.lang will likely never be accurate. Could still provide it as a default:

lang = self.config.get('lang', self.lang)

So a users config might then look like:

{
  "tts": {
    "module": "festival",
    "festival": {
      "lang": "italian"
    }
  }
}

cmd += " | festival --tts --language " + self.lang

self.begin_audio()
subprocess.call(cmd, shell=True)
Copy link
Contributor

@krisgesling krisgesling Jul 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shell=True has some security considerations so ideally we can avoid using it. Unfortunately you can't use a simple pipe character without it.

One option would be to split each command into it's own call and pipe using subprocesses built in method. Eg:

        text = subprocess.Popen(('echo', sentence), stdout=subprocess.PIPE)

        if encoding != 'utf8':
            convert_cmd = ('iconv', '-f', 'utf8', '-t', encoding)
            converted_text = subprocess.Popen(convert_cmd, 
                                              stdin=text.stdout,
                                              stdout=subprocess.PIPE)
            text.wait()
            text = converted_text

        tts_cmd = ('festival', '--tts', '--language', lang)
        self.begin_audio()
        subprocess.call(tts_cmd, stdin=text.stdout)
        text.wait()
        self.end_audio(listen)

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@jmontane
Copy link
Contributor Author

Hi, @krisgesling

Thanks for your help. I've tried my poor skills with git. I hope It's good enough now.

Regards

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

1 similar comment
@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@krisgesling
Copy link
Contributor

This looks perfect, nice work!

@krisgesling krisgesling merged commit 30177a0 into MycroftAI:dev Jul 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants