第一步,在腾讯云的语音识别的帮助文档,找不到语音识别的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.myzijiebao.com/丑小鸭在线朗读.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();
}
}
}