【问题标题】:How to convert the .wav audio files into text and identify the intents using LUIS如何将 .wav 音频文件转换为文本并使用 LUIS 识别意图
【发布时间】:2016-12-17 09:04:15
【问题描述】:

我正在使用机器人技术,在我当前的项目中,我实现了 Skype 通话功能,因为我确实录制了我的声音并存储到 Azure 存储 Blob,但我想要的功能是如何将音频文件转换为文本,然后识别意图在该文本中使用 LUIS。

这是我为将录制的内容上传到 Azure 存储而编写的代码。

   private async Task OnRecordCompleted(RecordOutcomeEvent recordOutcomeEvent)
    {

        if (recordOutcomeEvent.RecordOutcome.Outcome == Outcome.Success)
        {
            var record = await recordOutcomeEvent.RecordedContent;
            string path = HttpContext.Current.Server.MapPath($"~/{recordOutcomeEvent.RecordOutcome.Id}.wav");//Wma,wav,Mp3  ~/
            using (var writer = new FileStream(path, FileMode.Create))
            {
                await record.CopyToAsync(writer);
            }
            try
            {

                var storageConnectionString = ConfigurationManager.AppSettings["RealtimeAnamoly_StorageConnectionString"];

                Debug.WriteLine(storageConnectionString);

                var storageAccount = CloudStorageAccount.Parse(storageConnectionString);

                // We are going to use Blob Storage, so we need a blob client.
                var blobClient = storageAccount.CreateCloudBlobClient();

                // Data in blobs are organized in containers.
                // Here, we create a new, empty container.
                CloudBlobContainer blobContainer = blobClient.GetContainerReference("myfirstcontainer");
                blobContainer.CreateIfNotExists();

                // Retrieve reference to a blob named "myblob".
                CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference($"{recordOutcomeEvent.RecordOutcome.Id}.wav");

                // We also set the permissions to "Public", so anyone will be able to access the file.
                // By default, containers are created with private permissions only.
                blobContainer.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });

                // Create or overwrite the "myblob" blob with contents from a local file.
                using (var fileStream = System.IO.File.OpenRead(path))//@"path\myfile"
                {
                    blockBlob.UploadFromStream(fileStream);
                }

                //UploadAudioFiletoLuis(path);

                recordOutcomeEvent.ResultingWorkflow.Actions = new List<ActionBase>
                {
                    GetSilencePrompt(),
                    GetPromptForText("Successfully Recorded your message! Please wait for Response")

                    //CreateIvrOptions(AthenaIVROptions.ALS,1,true)

                };

            }
            catch (Exception ex)
            {

            }
        }
        else
        {
            if (silenceTimes > 1)
            {
                recordOutcomeEvent.ResultingWorkflow.Actions = new List<ActionBase>
                {
                    GetPromptForText("Thank you for calling"),
                    new Hangup() { OperationId = Guid.NewGuid().ToString() }
                };
                recordOutcomeEvent.ResultingWorkflow.Links = null;
                silenceTimes = 0;
            }
            else
            {
                silenceTimes++;
                recordOutcomeEvent.ResultingWorkflow.Actions = new List<ActionBase>
                {
                    GetRecordForText("I didn't catch that, would you kinly repeat?")
                };
            }
        }
    }

您能告诉我如何将 .wav 音频文件转换为文本,然后如何识别意图并从 LUIS 获得响应吗?

-Pradeep

【问题讨论】:

    标签: c# bots botframework microsoft-cognitive


    【解决方案1】:

    您应该查看Microsoft Cognitive Services Bing Speech API,因为它可以满足您的需求;将音频转换为文本。

    这里有一个使用 API 的sample。如果您向机器人发送 WAV 文件;它将以 API 从音频中理解的内容进行响应。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-31
      • 1970-01-01
      • 2014-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-12
      相关资源
      最近更新 更多