/// <summary> /// Recognize tag ID3 and metas datas music, from an audio file path /// Audio accepted: mp3, wav, m4a, flac, aac, amr, ape, ogg, wma ... /// </summary> /// <param name="filePath">path to the audio file</param> /// <returns></returns> public IEnumerable <MusicDao> Recognize(string filePath) { // TODO : check duration file before start to 30s var recognizer = new ACRCloudRecognizer(_apiHost, _apiKey, _apiSecretKey); var stuff = recognizer.RecognizeByFile(filePath, 100); var code = int.Parse(stuff.status?.code?.ToString() ?? "0"); // If match and no error code if (stuff != null && stuff.metadata != null && code == 0) { return(Map(stuff.metadata)); } // If no match if (code == 1001) { return(null); } // If an other error occurs var error = int.Parse(stuff.status.code.ToString()) switch { 3001 => "Missing/Invalid Access Key", 3002 => "Invalid ContentType. valid Content-Type is multipart/form-data", 3003 => "Limit exceeded", 3006 => "Invalid parameters", 3014 => "Invalid Signature", 3015 => "Could not generate fingerprint", _ => stuff?.status?.msg?.ToString() ?? "Unknow Error", }; throw new Exception(error); }
public void SendFileToApi(string a_fileForRecognisionSlin) { string m_jsonResultsSlin = musicRecogniserSlin.RecognizeByFile(a_fileForRecognisionSlin, 0); decodedJsonResultsSlin = JObject.Parse(m_jsonResultsSlin); }