コード例 #1
0
        public FileResult Speak(UserLanguages userLanguages, long id, SpeakerDataType type, bool mp3Support)
        {
            byte[] audioBytes = null;
            if (UserLanguages.IsValid(userLanguages) && IdValidator.IsValid(id))
            {
                audioBytes = GetPronunciation(id, type);
            }
            if (audioBytes == null)
            {
                audioBytes = new byte[0];
                LoggerWrapper.LogTo(LoggerName.Errors).ErrorFormat(
                    "SpeakerController.Speak. Для типа {0} с идентификатором {1} НЕ найдено произношение!",
                    type, id);
            }

            /*if (!mp3Support) {
             *  var audioConverter = new AudioConverter();
             *  byte[] result = audioConverter.ConvertMp3ToWav(audioBytes);
             *  if (result != null) {
             *      return File(result, "audio/wav");
             *  }
             * }*/

            return(File(audioBytes, "audio/mp3"));
        }