第一步,在腾讯云的语音识别的帮助文档,找不到语音识别的SDK。
找不到dotnet的SDK。
一句话语音识别
第二步,既然这里找不到的话,那我们就去GitHub的代码找一下:
github的地址:https://github.com/TencentCloud/tencentcloud-sdk-dotnet/tree/master/TencentCloud/Asr/V20190614
现在的发行版本是3.0.112.
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
录音文件识别结果查询:
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 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有