How to Set Up Google Cloud Speech Recognition 3.0 with Frostweep Games
To use Google Cloud Speech Recognition 3.0 in your project, follow these steps:
-
Add the Prefab:
Start by adding the GCSpeechRecognition prefab from FrostweepGames -> GCSpeechRecognition -> Prefabs folder to your scene.
-
Set the API Key:
Input your Google Cloud Speech Recognition API key into the Api Key field. If you want to use the API key from the prefab, check IsUseAPIKeyFromPrefab. Otherwise, it will use the key from Constants.cs. Get your API key here.
-
Create a Script:
Name your script Example, and write the core logic. Use the SpeechRecognizedSuccessEventHandler to manage the speech recognition response.
-
Access Recognition Result:
The result of the recognition can be retrieved via RecognitionResponse->results->alternatives->transcript, where RecognitionResponse is an object instance.
-
Start/Stop Recording:
- To start recording, call the respective method and include a boolean to enable runtime voice detection.
-
To stop recording, call the stop method.
-
Set Language:
To set the language, use the language setting method where the value is an integer cast to the LanguageCode enum.
-
Speech Contexts:
If needed, set the list of speech contexts by calling the appropriate method in your script.
By following these steps, you'll have successfully integrated Google Cloud Speech Recognition into your Unity project.
评论区