Exemple #1
0
    IEnumerator Synthesize()
    {
        int           counter   = 0;
        List <string> apiChunks = GetChunksFromStory();

        _textToSpeech.Voice = VoiceType.en_US_Allison;
        synthChunksSize     = apiChunks.Count;
        narrationClips      = new AudioClip[synthChunksSize];
        gatheringAudio      = true;
        loadingChunk        = true;

        Debug.Log("Gathering audio (this can take 30 seconds)");
        foreach (string chunk in apiChunks)
        {
            _textToSpeech.ToSpeech(OnSynthesize, OnFail, chunk, true);
            yield return(new WaitWhile(() => loadingChunk));

            loadingChunk = true;
        }
        storyData.addAudioClips(narrationClips);
        Debug.Log("Finished gathering story");
        storyData.doneLoading();
    }