Speech Recognition
SkillfulAPI.SpeechRecognition
SkillfulAPI.SpeechRecognitionOverview
Function Example
using SkillfulAI.API;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpeechRecognition : MonoBehaviour
{
/// <summary>
/// Unity's Update method, called once per frame. Checks for user input to start and stop recording.
/// </summary>
public void Update()
{
// Start recording when the space key is pressed down
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("Recording...");
AudioRecorder.StartRecording();
}
// Stop recording when the space key is released
if (Input.GetKeyUp(KeyCode.Space))
{
Debug.Log("Stopped!");
var bytes = AudioRecorder.StopRecordingAndGetBytes();
Debug.Log("Sending Bytes");
VoiceToText(bytes);
}
}
/// <summary>
/// Sends the recorded audio bytes to the SkillfulAPI for speech recognition.
/// </summary>
/// <param name="bytes">The recorded audio data in WAV format.</param>
public void VoiceToText(byte[] bytes)
{
SkillfulAPI.SpeechRecognition(bytes, response =>
{
Debug.Log(response);
});
}
}Detailed Explanation
Usage Example
Conclusion
Last updated