zoukankan      html  css  js  c++  java
  • MS Speech/ azure

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
    
    using System.IO;
    using Microsoft.CognitiveServices.Speech;
    using Microsoft.CognitiveServices.Speech.Audio;
    
    
    namespace SpeechRecTest
    {
        /// <summary>
        /// Interaction logic for AzureSpeechWind.xaml
        /// </summary>
        public partial class AzureSpeechWind : Window
        {
            public AzureSpeechWind()
            {
                InitializeComponent();
                Loaded += AzureSpeechWind_Loaded;
            }
    
            private  void AzureSpeechWind_Loaded(object sender, RoutedEventArgs e)
            {
               // var speechConfig = SpeechConfig.FromSubscription("8ec6730993d54cf9a9cec0f5d08b8e8b", "eastus");
                //var speechConfig = SpeechConfig.FromSubscription("<paste-your-speech-key-here>", "<paste-your-speech-location/region-here>");
                Start();
            }
    
            async static Task FromMic(SpeechConfig speechConfig)
            {
                 var audioConfig = AudioConfig.FromDefaultMicrophoneInput();
                 var recognizer = new SpeechRecognizer(speechConfig, audioConfig);
    
                Console.WriteLine("Speak into your microphone.");
                var result = await recognizer.RecognizeOnceAsync();
                Console.WriteLine($"RECOGNIZED: Text={result.Text}");
                
    
            }
    
            async static Task Start()
            {
                try
                {
                    // var speechConfig = SpeechConfig.FromSubscription("<paste-your-speech-key-here>", "<paste-your-speech-location/region-here>");
                    var speechConfig = SpeechConfig.FromSubscription("8ec6730993d54cf9a9cec0f5d08b8e8b", "eastus");
                    await FromMic(speechConfig);
                }
                catch(Exception ex) {
    
                    Console.WriteLine($"{ex.Message }");
    
                }
            }
    
        }
    }
    

      

    fffffffffffffffff
    test red font.
  • 相关阅读:
    浅谈 PHP 与手机 APP 开发(API 接口开发)
    Thinkphp+Nginx(PHPstudy)下报的404错误,403错误解决
    win7彻底卸载iis
    Java ByteCode 规格严格
    CPUID 规格严格
    Your First Plugin(转载) 规格严格
    SQLYog Enterprise注册码 规格严格
    WSUS API&&WUAPI 规格严格
    linux学习一则 规格严格
    Eclipse分析源代码时总是显示org.eclipse.core.runtime.CoreException错误,找不到***文件(转载) 规格严格
  • 原文地址:https://www.cnblogs.com/wgscd/p/15243772.html
Copyright © 2011-2022 走看看