Пример #1
0
        //metainfos https://docs.acrcloud.com/metadata
        static void Main(string[] args)
        {
            var config = new Dictionary<string, object>();
            config.Add("host", "XXXXXX");
            // Replace "XXXXXXXX" below with your project's access_key and access_secret
            config.Add("access_key", "XXXXXXXX");
            config.Add("access_secret", "XXXXXXXX");
            config.Add("timeout", 10); // seconds

            /**
              *
              *  recognize by file path of (Formatter: Audio/Video)
              *     Audio: mp3, wav, m4a, flac, aac, amr, ape, ogg ...
              *     Video: mp4, mkv, wmv, flv, ts, avi ...
              *
              *
             **/

            ACRCloudRecognizer re = new ACRCloudRecognizer(config);

            // It will skip 0 seconds from the beginning of test.mp3.
            string result = re.RecognizeByFile("test.mp3", 0);
            Console.WriteLine(result);

            /**
              *
              *  recognize by buffer of (Formatter: Audio/Video)
              *     Audio: mp3, wav, m4a, flac, aac, amr, ape, ogg ...
              *     Video: mp4, mkv, wmv, flv, ts, avi ...
              *
              *
              **/
            using (FileStream fs = new FileStream(@"test.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, 0);
                    Console.WriteLine(result);
                }
            }

            //ACRCloudExtrTool acrTool = new ACRCloudExtrTool();
            //byte[] fp = acrTool.CreateFingerprintByFile("test.mp3", 80, 12, false);
            //Console.WriteLine(fp.Length);

            //byte[] audioBuffer = acrTool.DecodeAudioByFile("test.mp3", 80, 0);
            //Console.WriteLine(audioBuffer.Length);

            /*using (FileStream fs = new FileStream(@"test.mp3", FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(fs))
                {
                    byte[] datas = reader.ReadBytes((int)fs.Length);
                    byte[] fpt = acrTool.CreateFingerprintByFileBuffer(datas, datas.Length, 80, 12, false);
                    Console.WriteLine(fpt.Length);
                }
            }*/

            Console.ReadLine();
        }
Пример #2
0
        //metainfos https://docs.acrcloud.com/metadata
        static void Main(string[] args)
        {
            var config = new Dictionary <string, object>();

            config.Add("host", "XXXXXX");
            // Replace "XXXXXXXX" below with your project's access_key and access_secret
            config.Add("access_key", "XXXXXXXX");
            config.Add("access_secret", "XXXXXXXX");
            config.Add("timeout", 10); // seconds

            /**
             *
             *  recognize by file path of (Formatter: Audio/Video)
             *     Audio: mp3, wav, m4a, flac, aac, amr, ape, ogg ...
             *     Video: mp4, mkv, wmv, flv, ts, avi ...
             *
             *
             **/

            ACRCloudRecognizer re = new ACRCloudRecognizer(config);

            // It will skip 0 seconds from the beginning of test.mp3.
            string result = re.RecognizeByFile("test.mp3", 0);

            Console.WriteLine(result);

            /**
             *
             *  recognize by buffer of (Formatter: Audio/Video)
             *     Audio: mp3, wav, m4a, flac, aac, amr, ape, ogg ...
             *     Video: mp4, mkv, wmv, flv, ts, avi ...
             *
             *
             **/
            using (FileStream fs = new FileStream(@"test.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, 0);
                    Console.WriteLine(result);
                }
            }

            //ACRCloudExtrTool acrTool = new ACRCloudExtrTool();
            //byte[] fp = acrTool.CreateFingerprintByFile("test.mp3", 80, 12, false);
            //Console.WriteLine(fp.Length);

            //byte[] audioBuffer = acrTool.DecodeAudioByFile("test.mp3", 80, 0);
            //Console.WriteLine(audioBuffer.Length);

            /*using (FileStream fs = new FileStream(@"test.mp3", FileMode.Open))
             * {
             *  using (BinaryReader reader = new BinaryReader(fs))
             *  {
             *      byte[] datas = reader.ReadBytes((int)fs.Length);
             *      byte[] fpt = acrTool.CreateFingerprintByFileBuffer(datas, datas.Length, 80, 12, false);
             *      Console.WriteLine(fpt.Length);
             *  }
             * }*/

            Console.ReadLine();
        }