private unsafe Result CreateQuery(IntPtr devicePointer, QueryType queryType, IntPtr **queryInterface) { throw new NotSupportedException("Can't write interop, and this function doesn't seem necessary."); try { this.Log.LogMethodSignatureTypesAndValues(devicePointer, queryType, "ref"); this.GetOrCreateDevice(devicePointer); if (**queryInterface == IntPtr.Zero) { return(Result.Ok); } else { this.Queries.Add(new Query(**queryInterface)); //queryInterface = this.Queries.Last().NativePointer; return(Result.Ok); } } catch (SharpDXException ex) { Log.Warn(ex); return(ex.ResultCode); } catch (Exception ex) { this.Log.Fatal(ex); return(Result.UnexpectedFailure); } }
/// <summary> /// Creates a new streaming inference state. /// </summary> public unsafe DeepSpeechStream CreateStream() { IntPtr **streamingStatePointer = null; var resultCode = NativeImp.DS_CreateStream(_modelStatePP, ref streamingStatePointer); EvaluateResultCode(resultCode); return(new DeepSpeechStream(streamingStatePointer)); }
/// <summary> /// Creates a new streaming inference state. /// </summary> public unsafe MozillaVoiceSttStream CreateStream() { IntPtr **streamingStatePointer = null; var resultCode = NativeImp.STT_CreateStream(_modelStatePP, ref streamingStatePointer); EvaluateResultCode(resultCode); return(new MozillaVoiceSttStream(streamingStatePointer)); }
/// <summary> /// This is the bootstrapping entry point. It's labeled private but is actually invoked from the native /// code to poke the address of the FnGetter callback into the address encoded in the string parameter. /// This odd way of doing things is because the most convenient way to call an initial managed method /// imposes the signature of Func{string, int}, which doesn't allow us to return a function adress. /// </summary> private static unsafe int GetFnGetterCallback(string addr) { if (FnGetter == null) { Interlocked.CompareExchange(ref FnGetter, (NativeFnGetter)GetFn, null); } long a = long.Parse(addr); IntPtr * p = null; IntPtr **pp = &p; *(long *)pp = a; *p = Marshal.GetFunctionPointerForDelegate(FnGetter); return(1); }
internal unsafe static extern int DS_GetModelSampleRate(IntPtr **aCtx);
/// <summary> /// Initializes a new instance of <see cref="MozillaVoiceSttStream"/>. /// </summary> /// <param name="streamingStatePP">Native pointer of the native stream.</param> public unsafe MozillaVoiceSttStream(IntPtr **streamingStatePP) { _streamingStatePp = streamingStatePP; }
internal static unsafe extern IntPtr DS_FinishStreamWithMetadata(IntPtr **aSctx);
internal static unsafe extern IntPtr DS_IntermediateDecode(IntPtr **aSctx);
internal static unsafe extern void DS_FreeStream(IntPtr **aSctx);
internal static unsafe extern void DS_FreeModel(IntPtr **aCtx);
internal static unsafe extern ErrorCodes DS_SetScorerAlphaBeta(IntPtr **aCtx, float aAlpha, float aBeta);
public static extern IntPtr GetDeviceList(Context ctx, IntPtr **list);
internal static unsafe extern int RoParseTypeName( HSTRING typename, uint *typenamePartsLength, IntPtr **typenameParts);
public extern static unsafe int clEnqueueWriteImage(IntPtr command_queue, IntPtr image, bool blocking_write, IntPtr **origin, IntPtr **region, IntPtr input_row_pitch, IntPtr input_slice_pitch, IntPtr ptr, uint num_events_in_wait_list, IntPtr *event_wait_list, IntPtr * @event);
public extern static unsafe System.IntPtr clEnqueueMapImage(IntPtr command_queue, IntPtr image, bool blocking_map, uint map_flags, IntPtr **origin, IntPtr **region, IntPtr *image_row_pitch, IntPtr *image_slice_pitch, uint num_events_in_wait_list, IntPtr *event_wait_list, IntPtr * @event, out int errcode_ret);
public extern static unsafe int clEnqueueCopyImageToBuffer(IntPtr command_queue, IntPtr src_image, IntPtr dst_buffer, IntPtr **src_origin, IntPtr **region, IntPtr dst_offset, uint num_events_in_wait_list, IntPtr *event_wait_list, IntPtr * @event);
public unsafe void Dispose() => _streamingStatePp = null;
internal static unsafe extern ErrorCodes DS_EnableExternalScorer(IntPtr **aCtx, string aScorerPath);
internal static unsafe extern ErrorCodes DS_DisableExternalScorer(IntPtr **aCtx);
internal static unsafe extern ErrorCodes DS_EnableDecoderWithLM(IntPtr **aCtx, string aLMPath, string aTriePath, float aLMAlpha, float aLMBeta);
internal static unsafe extern IntPtr DS_SpeechToTextWithMetadata(IntPtr **aCtx, short[] aBuffer, uint aBufferSize);
public abstract unsafe Result GetMemoryAndroidHardwareBuffer([Count(Count = 0)] Device device, [Count(Count = 0), Flow(FlowDirection.In)] MemoryGetAndroidHardwareBufferInfoANDROID *pInfo, [Count(Count = 0), Flow(FlowDirection.Out)] IntPtr **pBuffer);
internal static unsafe extern ErrorCodes DS_CreateStream(IntPtr **aCtx, ref IntPtr **retval);
internal unsafe static extern uint DS_GetModelBeamWidth(IntPtr **aCtx);
internal static unsafe extern void DS_FeedAudioContent(IntPtr **aSctx, short[] aBuffer, uint aBufferSize);
internal extern static unsafe ErrorCode EnqueueCopyBufferToImage(IntPtr command_queue, IntPtr src_buffer, IntPtr dst_image, IntPtr src_offset, IntPtr **dst_origin, IntPtr **region, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr * @event);
internal static unsafe extern IntPtr DS_FinishStream(IntPtr **aSctx);
internal unsafe static extern ErrorCodes DS_CreateModel(string aModelPath, uint aBeamWidth, ref IntPtr **pint);
internal unsafe static extern ErrorCodes DS_SetModelBeamWidth(IntPtr **aCtx, uint aBeamWidth);
internal extern static unsafe ErrorCode EnqueueReadImage(IntPtr command_queue, IntPtr image, bool blocking_read, IntPtr **origin, IntPtr **region, IntPtr row_pitch, IntPtr slice_pitch, IntPtr ptr, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr * @event);