NPBruce / valkyrie

Valkyrie GM for Fantasy Flight Board Games
Apache License 2.0
506 stars 105 forks source link

Add text to speech for events #390

Open redwolf2 opened 7 years ago

redwolf2 commented 7 years ago

Having to read all the text from a computer screen is tireing. Optional TTS could really improve the scenarios, even with a robot voice. IMO this issue should have no prio yet, but is a very nice to have.

I fiddled around with System.Speech.

while (true)
{
    using (var synthesizer = new SpeechSynthesizer())
    {
        // show installed voices
        foreach (var v in synthesizer.GetInstalledVoices().Select(v => v.VoiceInfo))
        {
            Console.WriteLine("Name:{0}, Description:{1}, Gender:{2}, Age:{3}",
                v.Name, v.Description, v.Gender, v.Age);
        }

        // select audio device
        synthesizer.SetOutputToDefaultAudioDevice();

        // build and speak a prompt
        var builder = new PromptBuilder();
        builder.AppendText("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!");
        synthesizer.Speak(builder);
    }
}

The API seem to be also available on Mono. http://www.go-mono.com/status/status.aspx?reference=4.0&profile=4.5&assembly=System.Speech

LordPyrex commented 7 years ago

Awww, but that's one of my favorite things to do! And I like to make different voices for each character that speaks.

redwolf2 commented 7 years ago

Entirely optional ;)

LordPyrex commented 7 years ago

Yeah, the only problem that I have with text to speech is how dry it comes out sounding. I guess you can just imagine Stephen Hawking narrating your story!

redwolf2 commented 7 years ago

https://www.youtube.com/watch?v=5bueZoYhUlg&t=58s

The problem is, there are many TTS services and engines available, but poor in quality, choice of languages or features. Most of them sound very similar – quite good but uncanny. The best ones are only available via cloud based services you need to pay for, like the Bing Spech API from MS Azure or Amazon Polly. The most promising today is Google Wavenet, but that isn't available to the public yet. The poor man approach to this would be to just utilize a good offline speech engine, that is available on the specific plattform. I doubt, that there is one, that is available on all plattforms in all required languages. For Windows, there is System.Speech, that performs quite ok.

Maybe a better idea: The scenarios might later support voice synchronization via audiofiles from a narrator. Just create a crawler with a good cloud based service, that generates the speech audio files based on the static text and use that for scenarios that are lacking a narrator.

The best engine, that allows for audio file distribution is probably Amazon Polly according to their FAQ and it allows 5 millon chars per month for free, however you need to register with a credit card.

NPBruce commented 7 years ago

That is a reasonable suggestion, perhaps this isn't a Valkyrie thing after all then? If I support different audio based on language it can be up to the scenario author.

antroids commented 3 years ago

Hi guys! I spent a couple of days and integrated Google TTS. API key with enabled Cloud TTS required, it would be better to create new for only Valkyrie. Limitations for WaveNet are: 1 million chars per month for free. Supported voices: https://cloud.google.com/text-to-speech/docs/voices

My fork is here: https://github.com/antroids/valkyrie Feel free to use this code.

TODO: 1) Handle limitation in 500 symbols for one request. 2) Add auto play. 3) Implement caching.