123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- using System;
- using Pico.Platform.Models;
- namespace Pico.Platform
- {
- public class SpeechService
- {
-
-
-
-
- public static AsrEngineInitResult InitAsrEngine()
- {
- return CLIB.ppf_Speech_InitAsrEngine();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static int StartAsr(bool autoStop, bool showPunctual, int vadMaxDurationInSeconds)
- {
- var option = new StartAsrOptions();
- option.SetAutoStop(autoStop);
- option.SetShowPunctual(showPunctual);
- option.SetVadMaxDurationInSeconds(vadMaxDurationInSeconds);
- return CLIB.ppf_Speech_StartAsr((IntPtr) option);
- }
-
-
-
- public static void StopAsr()
- {
- CLIB.ppf_Speech_StopAsr();
- }
-
-
-
-
-
-
- public static void SetOnAsrResultCallback(Message<AsrResult>.Handler handler)
- {
- Looper.RegisterNotifyHandler(MessageType.Notification_Speech_OnAsrResult, handler);
- }
-
-
-
-
- public static void SetOnSpeechErrorCallback(Message<SpeechError>.Handler handler)
- {
- Looper.RegisterNotifyHandler(MessageType.Notification_Speech_OnSpeechError, handler);
- }
- }
- public class StartAsrOptions
- {
- public StartAsrOptions()
- {
- Handle = CLIB.ppf_StartAsrOptions_Create();
- }
-
- public void SetAutoStop(bool value)
- {
- CLIB.ppf_StartAsrOptions_SetAutoStop(Handle, value);
- }
-
- public void SetVadMaxDurationInSeconds(int value)
- {
- CLIB.ppf_StartAsrOptions_SetVadMaxDurationInSeconds(Handle, value);
- }
-
- public void SetShowPunctual(bool value)
- {
- CLIB.ppf_StartAsrOptions_SetShowPunctual(Handle, value);
- }
-
- public static explicit operator IntPtr(StartAsrOptions options)
- {
- return options != null ? options.Handle : IntPtr.Zero;
- }
- ~StartAsrOptions()
- {
- CLIB.ppf_StartAsrOptions_Destroy(Handle);
- }
- public IntPtr Handle;
- }
- }
|