2016-08-17 45 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」存儲桶附加到您的項目中,然後您應該能夠識別音樂。