コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】iOS / Android で音声合成(TextToSpeech)使用できる「Speech And Text in Unity iOS and Unity Android」紹介

概要

「Speech And Text in Unity iOS and Unity Android」を
Unity プロジェクトに導入することで
iOS / Android で音声合成(TextToSpeech)使用できるようになります

使い方

using TextSpeech;
using UnityEngine;

public class Example : MonoBehaviour
{
    private void Start()
    {
        var textToSpeech = TextToSpeech.Instance;

        // 設定
        textToSpeech.Setting
        (
            language: "ja_JP",
            _pitch: 1,
            _rate: 1
        );

        // 再生
        textToSpeech.StartSpeak( "ピカチュウ" );
        
        // 停止
        // textToSpeech.StopSpeak();
    }
}