Watosonを使ってUnityの中にいるキャラクターと会話させたい
制作したものをrunさせた時に起きました。
発生している問題・エラーメッセージ
Assets/UnityChan/Scripts/SampleSpeechToText.cs(32,24): error CS1501: No overload for method `Recognize' takes `2' arguments Assets/UnityChan/Scripts/SampleSpeechToText.cs(12,43): error CS1729: The type `IBM.Watson.DeveloperCloud.Services.SpeechToText.v1.SpeechToText' does not contain a constructor that takes `0' arguments
該当のソースコード
//SampleSpeechToText.cs using System.Collections; using System.Collections.Generic; using UnityEngine; using IBM.Watson.DeveloperCloud.Services.SpeechToText.v1; public class SampleSpeechToText : MonoBehaviour { [SerializeField] private AudioClip m_AudioClip = new AudioClip(); private SpeechToText m_SpeechToText = new SpeechToText(); // Use this for initialization IEnumerator Start() { // 音声をマイクから 3 秒間取得する Debug.Log ("Start record"); //集音開始 var audioSource = GetComponent<AudioSource>(); audioSource.clip = Microphone.Start(null, true, 10, 44100); audioSource.loop = false; audioSource.spatialBlend = 0.0f; yield return new WaitForSeconds (3f); Microphone.End (null); //集音終了 Debug.Log ("Finish record"); // ためしに録音内容を再生してみる audioSource.Play (); // SpeechToText を日本語指定して、録音音声をテキストに変換 m_SpeechToText.RecognizeModel = "ja-JP_BroadbandModel"; m_SpeechToText.Recognize(audioSource.clip, HandleOnRecognize); } void HandleOnRecognize(SpeechRecognitionEvent result) { if (result != null && result.results.Length > 0) { foreach (var res in result.results) { foreach (var alt in res.alternatives) { string text = alt.transcript; Debug.Log(string.Format("{0} ({1}, {2:0.00})\n", text, res.final ? "Final" : "Interim", alt.confidence)); } } } } // Update is called once per frame void Update () { } }
試したこと
自分でコードを読んで見たりしたのですが、c#に触れるのが初めてに近くて自分の力だけでは解決できませんでした。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。