/// <summary>
        /// Note: the calling code expects a Task with a return value for consistency with
        /// other samples.
        /// We'll always return a task which eventually faults or returns 0.
        /// </summary>
        public static async Task <int> RecognizeAsync()
        {
            var instance = new InfiniteStreaming();
            await instance.RunAsync();

            return(0);
        }
Esempio n. 2
0
 public static int Main(string[] args)
 {
     return((int)Parser.Default.ParseArguments <
                SyncOptions, AsyncOptions,
                StreamingOptions, ListenOptions, ListenInfiniteOptions,
                RecOptions, SyncOptionsWithCreds,
                OptionsWithContext
                >(args).MapResult(
                (SyncOptions opts) => IsStorageUri(opts.FilePath) ?
                SyncRecognizeGcs(opts.FilePath) : opts.EnableWordTimeOffsets ?
                SyncRecognizeWords(opts.FilePath) : opts.EnableProfanityFilter ?
                SyncRecognizeWithProfanityFilterGcs(opts.FilePath) : opts.MultiRegion ?
                SyncRecognizeWithMultiRegionGcs(opts.FilePath) : opts.EnableAutomaticPunctuation ?
                SyncRecognizePunctuation(opts.FilePath) : (opts.SelectModel != null) ?
                SyncRecognizeModelSelection(opts.FilePath, opts.SelectModel) : opts.UseEnhancedModel ?
                SyncRecognizeEnhancedModel(opts.FilePath) : (opts.NumberOfChannels > 1) ?
                SyncRecognizeMultipleChannels(opts.FilePath, opts.NumberOfChannels) : (opts.NumberOfSpeakers > 1) ?
                SyncRecognizeMultipleSpeakers(opts.FilePath, opts.NumberOfSpeakers) : opts.UseRecognitionMetadata ?
                SyncRecognizeRecognitionMetadata(opts.FilePath) : SyncRecognize(opts.FilePath),
                (AsyncOptions opts) => IsStorageUri(opts.FilePath) ?
                (opts.EnableWordTimeOffsets ? AsyncRecognizeGcsWords(opts.FilePath)
             : AsyncRecognizeGcs(opts.FilePath))
             : LongRunningRecognize(opts.FilePath),
                (StreamingOptions opts) => StreamingRecognizeAsync(opts.FilePath).Result,
                (ListenOptions opts) => StreamingMicRecognizeAsync(opts.Seconds).Result,
                (ListenInfiniteOptions opts) => InfiniteStreaming.RecognizeAsync().Result,
                (RecOptions opts) => Rec(opts.FilePath, opts.BitRate, opts.Encoding),
                (SyncOptionsWithCreds opts) => SyncRecognizeWithCredentials(
                    opts.FilePath, opts.CredentialsFilePath),
                (OptionsWithContext opts) => RecognizeWithContext(opts.FilePath, ReadPhrases()),
                errs => 1));
 }
        static void Main(string[] args)
        {
            var ct = new CancellationTokenSource();

            using (var i = InfiniteStreaming.ListenToWhatsPlayingOnMyHeadset(new MyctBridge(args[0])))
            {
                Console.WriteLine($"Listening to it, say exit to stop");
                i.RecognizeAsync(ct.Token).Wait();

                ct.Cancel();
                return;
            }
        }