前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >腾讯云语音识别.net-sdk使用笔记0818

腾讯云语音识别.net-sdk使用笔记0818

原创
作者头像
算法发
发布2020-08-18 16:47:21
1.7K0
发布2020-08-18 16:47:21
举报

第一步,在腾讯云的语音识别的帮助文档,找不到语音识别的SDK。

找不到dotnet的SDK。

一句话语音识别

第二步,既然这里找不到的话,那我们就去GitHub的代码找一下:

github的地址:https://github.com/TencentCloud/tencentcloud-sdk-dotnet/tree/master/TencentCloud/Asr/V20190614

现在的发行版本是3.0.112.

代码语言:javascript
复制
using System;
using System.Threading.Tasks;
using TencentCloud.Common;
using TencentCloud.Common.Profile;
using TencentCloud.Asr.V20190614;
using TencentCloud.Asr.V20190614.Models;

namespace TencentCloudExamples
{
    class SentenceRecognition
    {
        static void Main(string[] args)
        {
            try
            {
                Credential cred = new Credential
                {
                    SecretId = "SecretId",
                    SecretKey = "SecretKey"
                };

                ClientProfile clientProfile = new ClientProfile();
                HttpProfile httpProfile = new HttpProfile();
                httpProfile.Endpoint = ("asr.tencentcloudapi.com");
                clientProfile.HttpProfile = httpProfile;

                AsrClient client = new AsrClient(cred, "", clientProfile);
                SentenceRecognitionRequest req = new SentenceRecognitionRequest();
                string strParams = "{\"ProjectId\":0,\"SubServiceType\":2,\"EngSerViceType\":\"8k_zh\",\"SourceType\":0,\"Url\":\"https://asr-1257125007.cos.ap-guangzhou.myqcloud.com/%E4%B8%91%E5%B0%8F%E9%B8%AD%E5%9C%A8%E7%BA%BF%E6%9C%97%E8%AF%BB.mp3\",\"VoiceFormat\":\"mp3\",\"UsrAudioKey\":\"asr0624\"}";
                req = SentenceRecognitionRequest.FromJsonString<SentenceRecognitionRequest>(strParams);
                SentenceRecognitionResponse resp = client.SentenceRecognitionSync(req);
                Console.WriteLine(AbstractModel.ToJsonString(resp));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            Console.Read();
        }
    }
}

错误的代码:

message:The request with exception: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 requestId

录音文件识别结果查询:

代码语言:javascript
复制
using System;
using System.Threading.Tasks;
using TencentCloud.Common;
using TencentCloud.Common.Profile;
using TencentCloud.Asr.V20190614;
using TencentCloud.Asr.V20190614.Models;

namespace TencentCloudExamples
{
    class DescribeTaskStatus
    {
        static void Main(string[] args)
        {
            try
            {
                Credential cred = new Credential
                {
                    SecretId = "SecretId",
                    SecretKey = "SecretKey"
                };

                ClientProfile clientProfile = new ClientProfile();
                HttpProfile httpProfile = new HttpProfile();
                httpProfile.Endpoint = ("asr.tencentcloudapi.com");
                clientProfile.HttpProfile = httpProfile;

                AsrClient client = new AsrClient(cred, "ap-guangzhou", clientProfile);
                DescribeTaskStatusRequest req = new DescribeTaskStatusRequest();
                string strParams = "{\"TaskId\":859181183}";
                req = DescribeTaskStatusRequest.FromJsonString<DescribeTaskStatusRequest>(strParams);
                DescribeTaskStatusResponse resp = client.DescribeTaskStatusSync(req);
                Console.WriteLine(AbstractModel.ToJsonString(resp));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            Console.Read();
        }
    }
}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
作者已关闭评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
语音识别
腾讯云语音识别(Automatic Speech Recognition,ASR)是将语音转化成文字的PaaS产品,为企业提供精准而极具性价比的识别服务。被微信、王者荣耀、腾讯视频等大量业务使用,适用于录音质检、会议实时转写、语音输入法等多个场景。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档