2016-08-17 23 views
0

嘿所有我从ACRCloud C#演示下面的代码:ACRCloud歌承认

static void Main(string[] args) 
{ 
    var config = new Dictionary<string, object>(); 

    config.Add("host", "us-west-2.api.acrcloud.com"); 
    config.Add("access_key", "key here...."); 
    config.Add("access_secret", "secret here..."); 
    config.Add("timeout", 10); // seconds 

    ACRCloudRecognizer re = new ACRCloudRecognizer(config); 

    // It will skip 0 seconds from the beginning of test.mp3. 
    string result = re.RecognizeByFile("C:\\temp\\acrcloud_sdk_csharp-master\\01Track01.mp3", 80); 
    //string result2 = re.Recognize("C:\\temp\\acrcloud_sdk_csharp-master\\01Track01", 80); 
    Console.WriteLine(result); 

    using (FileStream fs = new FileStream(@"C:\temp\acrcloud_sdk_csharp-master\01Track01.mp3", FileMode.Open)) 
    { 
     using (BinaryReader reader = new BinaryReader(fs)) 
     { 
      byte[] datas = reader.ReadBytes((int)fs.Length); 
      // It will skip 0 seconds from the beginning of datas. 
      result = re.RecognizeByFileBuffer(datas, datas.Length, 80); 
      Console.WriteLine(result); 
     } 
    } 

    Console.ReadLine(); 
} 

对于这两种结果我得到的回报:

{"status":{ 
    "msg":"No result", 
    "code":1001, 
    "version":"1.0" 
}} 

不知道我是什么做不正确的....任何帮助将是伟大的!

+0

林不知道你在做什么错的,但也许尝试使用此示例代码? https://github.com/acrcloud/webapi_example/blob/master/identify%20protocol%201%20(recommended)/IdentifyProtocolV1.cs – rideon88

+0

即产生相同的结果。 – StealthRT

回答

0

我检查您所创建的是你连接你自己的水桶这个项目的问题项目,但你并没有任何文件上传到这个桶,换句话说:你的数据库是空的,这就是为什么你不能认识到什么。如果您想识别音乐,请参阅this tutorial,并将“ACRCloud Music”存储桶附加到您的项目中,然后您应该能够识别音乐。