Exemple #1
0
        public async Task <ActionResult <AudioModel> > UploadDialogAudio()
        {
            try
            {
                var file = Request.Form.Files[0];
                if (file.Length > 0)
                {
                    string audioPath = await _messageService.UploadDialogAudio(file);

                    AudioModel audio = new AudioModel()
                    {
                        AudioPath = audioPath
                    };
                    return(audio);
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
        private async Task MyAudio(object o)
        {
            AudioItemsViewModel = null;
            AudioModel audioModel = await _vkApi.Audio.GetAsync();

            Add(audioModel, true);
        }
        private void TeamplatesDictonary_AudioAdd(AudioModel audioModel, object sender)
        {
            var Awaiter = Tools.VkApi.Audio.AddAsync(audioModel.ID, audioModel.Owner_ID, audioModel.AccessKey).GetAwaiter();

            Awaiter.OnCompleted(() =>
            {
                if (Awaiter.GetResult() != 0)
                {
                    ((Button)sender).Content = System.Net.WebUtility.HtmlDecode("&#xE73E;");
                    var newModel             = new AudioModel()
                    {
                        AccessKey       = audioModel.AccessKey,
                        Artist          = audioModel.Artist,
                        AudioUrl        = audioModel.AudioUrl,
                        ImageUrl        = audioModel.ImageUrl,
                        Title           = audioModel.Title,
                        DurationSeconds = audioModel.DurationSeconds,
                        Owner_ID        = (long)Tools.VkApi.UserId,
                        ID = Awaiter.GetResult(),
                    };
                    this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
                    {
                        Tools.AddDataToObservationCollection(_MyAudiosPage.AudioCollection, newModel);
                        _MyAudiosPage.AudioCollection.Move(_MyAudiosPage.AudioCollection.Count - 1, 0);
                    }));
                }
            });
        }
        private void TeamplatesDictonary_AudioDeleteClicked(AudioModel audioModel)
        {
            var taskAwaiter = Tools.VkApi.Audio.DeleteAsync(audioModel.ID, audioModel.Owner_ID).GetAwaiter();

            taskAwaiter.OnCompleted(() =>
            {
                var taskAwaiter2 = Tools.VkApi.Audio.GetByIdAsync(new String[]
                                                                  { audioModel.ID.ToString() + "_" + audioModel.Owner_ID.ToString() }).GetAwaiter();
                taskAwaiter2.OnCompleted(() =>
                {
                    try
                    {
                        var res = taskAwaiter2.GetResult();
                    }
                    catch (VkNet.Exception.ParameterMissingOrInvalidException ex)
                    {
                        this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
                        {
                            if (MyAudiosTab.IsSelected)
                            {
                                _MyAudiosPage.AudioCollection.Remove(audioModel);
                            }

                            if (MyPlayliststab.IsSelected)
                            {
                                _AlbumsPage.AudioCollection.Remove(audioModel);
                            }
                        }));
                    }
                });
            });
        }
        private async Task SearchAudio(object o)
        {
            AudioItemsViewModel = null;
            AudioModel audioModel = await _vkApi.Audio.SearchAsync(SearchString);

            Add(audioModel, false);
        }
    public static AudioModel FromMp3DataModel(ref byte[] data)
    {
        AudioModel model = null;

        try {
            // Load the data into a stream
            using (MemoryStream mp3stream = new MemoryStream(data)) {
                // Convert the data in the stream to WAV format
                using (Mp3FileReader mp3audio = new Mp3FileReader(mp3stream)) {
                    // Load the data into a stream
                    using (WaveStream waveStream = WaveFormatConversionStream.CreatePcmStream(mp3audio)) {
                        // Convert to WAV data
                        using (MemoryStream memoryStream = AudioMemStream(waveStream)) {
                            byte[] conversedData = memoryStream.ToArray();
                            WAV    wav           = new WAV(ref conversedData);
                            Debug.Log(wav);

                            model               = new AudioModel();
                            model.name          = "temp";
                            model.lengthSamples = wav.SampleCount;
                            model.channel       = 1;
                            model.frequency     = wav.Frequency;
                            model.stream        = false;
                            model.data          = wav.LeftChannel;
                        }
                    }
                }
            }
        } catch (Exception e) {
            Debug.Log(e.Message);
        }
        return(model);
    }
        private void TeamplatesDictonary_AudioDownload(AudioModel audioModel, object sender)
        {
            var AudioAwaiter = Tools.VkApi.Audio.GetByIdAsync(new string[] { audioModel.Owner_ID + "_" + audioModel.ID.ToString() + "_" + audioModel.AccessKey }).GetAwaiter();

            AudioAwaiter.OnCompleted(() =>
            {
                using (WebClient webClient = new WebClient())
                {
                    webClient.DownloadFileCompleted += delegate(object sender1, System.ComponentModel.AsyncCompletedEventArgs e)
                    {
                        ((Button)sender).Content = System.Net.WebUtility.HtmlDecode("&#xE73E;");
                    };

                    try
                    {
                        var audiodataen = AudioAwaiter.GetResult().GetEnumerator();
                        audiodataen.MoveNext();
                        var audiodata = audiodataen.Current;

                        webClient.DownloadFileAsync(new Uri(audiodata.Url.AbsoluteUri), Tools.settings.CurrentSettings.VKAudioDownloadPath + "\\" + audiodata.Artist + "-" + audiodata.Title + ".mp3");;
                    }

                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                    }
                }
            });
        }
Exemple #8
0
        public void TestAudioGet()
        {
            AudioModel qwe = _vkApi.Audio.Get();

            Assert.AreEqual(qwe.response.count, 604);
            Assert.AreEqual(qwe.response.items.Count, 10);
        }
        public JsonResult List()
        {
            var mongo  = new MongoHelper();
            var scenes = mongo.FindAll(Constant.AudioCollectionName);

            var list = new List <AudioModel>();

            foreach (var i in scenes)
            {
                var info = new AudioModel
                {
                    ID          = i["ID"].AsObjectId.ToString(),
                    Name        = i["Name"].AsString,
                    TotalPinYin = i["TotalPinYin"].ToString(),
                    FirstPinYin = i["FirstPinYin"].ToString(),
                    Type        = i["Type"].AsString,
                    Url         = i["Url"].AsString,
                    CreateTime  = i["CreateTime"].ToUniversalTime(),
                    UpdateTime  = i["UpdateTime"].ToUniversalTime()
                };
                list.Add(info);
            }

            list = list.OrderByDescending(o => o.UpdateTime).ToList();

            return(Json(new
            {
                Code = 200,
                Msg = "获取成功!",
                Data = list
            }));
        }
    public static AudioClip FromMp3Data(byte[] data)
    {
        AudioModel model     = FromMp3DataModel(ref data);
        AudioClip  audioClip = AudioClip.Create(model.name, model.lengthSamples, model.channel, model.frequency, model.stream);

        audioClip.SetData(model.data, 0);
        return(audioClip);
    }
    public static AudioClip ByteArrayToAudioClip(byte[] wavFile, string name = "", bool stream = false)
    {
        AudioModel model = ByteArrayToAudioClipModel(wavFile);
        // Create the AudioClip:
        AudioClip audioClip = AudioClip.Create(model.name, model.lengthSamples, model.channel, model.frequency, model.stream);

        audioClip.SetData(model.data, 0);
        return(audioClip);
    }
 private VideoModels(int formatCode, VideoQuality videoQuality, int resolution, bool is3D, AudioModel audioModel, int audioBitrate, Type Type)
 {
     this.FormatCode = formatCode;
     this.VideoQuality = videoQuality;
     this.Resolution = resolution;
     this.Is3D = is3D;
     this.AudioModel = audioModel;
     this.AudioBit = audioBitrate;
     this.Type = Type;
 }
        private async Task AudioRecommended(object o)
        {
            if (ItemSelected != null)
            {
                string targetAudio = ItemSelected.OwnerId + "_" + ItemSelected.Id;
                AudioItemsViewModel = null;
                AudioModel audioModel = await _vkApi.Audio.GetRecommendationsAsync(targetAudio);

                Add(audioModel, false);
            }
        }
Exemple #14
0
 public void AdicionarModelo(AudioModel modelo)
 {
     if (!_classes.ContainsKey(modelo.IdentificadorModelo))
     {
         _classes.Add(modelo.IdentificadorModelo, modelo);
     }
     else
     {
         throw new ArgumentException("Modelo já cadastrado.");
     }
 }
Exemple #15
0
        public JsonResult List()
        {
            var mongo = new MongoHelper();

            // 获取所有类别
            var filter = Builders <BsonDocument> .Filter.Eq("Type", "Audio");

            var categories = mongo.FindMany(Constant.CategoryCollectionName, filter).ToList();

            var audios = mongo.FindAll(Constant.AudioCollectionName).ToList();

            var list = new List <AudioModel>();

            foreach (var i in audios)
            {
                var categoryID   = "";
                var categoryName = "";

                if (i.Contains("Category") && !i["Category"].IsBsonNull && !string.IsNullOrEmpty(i["Category"].ToString()))
                {
                    var doc = categories.Where(n => n["_id"].ToString() == i["Category"].ToString()).FirstOrDefault();
                    if (doc != null)
                    {
                        categoryID   = doc["_id"].ToString();
                        categoryName = doc["Name"].ToString();
                    }
                }

                var info = new AudioModel
                {
                    ID           = i["ID"].AsObjectId.ToString(),
                    Name         = i["Name"].AsString,
                    CategoryID   = categoryID,
                    CategoryName = categoryName,
                    TotalPinYin  = i["TotalPinYin"].ToString(),
                    FirstPinYin  = i["FirstPinYin"].ToString(),
                    Type         = i["Type"].AsString,
                    Url          = i["Url"].AsString,
                    CreateTime   = i["CreateTime"].ToUniversalTime(),
                    UpdateTime   = i["UpdateTime"].ToUniversalTime()
                };
                list.Add(info);
            }

            list = list.OrderByDescending(o => o.UpdateTime).ToList();

            return(Json(new
            {
                Code = 200,
                Msg = "Get Successfully!",
                Data = list
            }));
        }
Exemple #16
0
        protected override void Start()
        {
            base.Start();

            gameModel  = Models.GetModel <GameModel>();
            carModel   = Models.GetModel <CarModel>();
            audioModel = Models.GetModel <AudioModel>();

            gameModel.OnLapUpdated    += PlayerForceFieldAudio;
            carModel.OnTurningUpdated += OnTurningUpdated;

            PlayCarEngineAudio();

            EventManager <Events> .RegisterEvent(Events.FailConditionMet, OnDeathConditionMet);
        }
        /// <summary>
        /// Controller action answering GET http-requests for RQItems
        /// </summary>
        /// <returns>
        /// Standard view
        /// </returns>
        public ActionResult Index(string rqitemId, string itemAdress)
        {
            ViewBag.DocNo = rqitemId;
            if (itemAdress.StartsWith("MyDocs"))
            {
                ItemViewerModel theModel;

                if ((!_bRedirectToRemote) &&
                    (System.Web.HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST").ToLower() == "localhost") || (System.Web.HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST").ToLower() == "admin-pc"))
                {
                    theModel = new ItemViewerModel(rqitemId, "http://" + System.Web.HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST") + "/" + itemAdress);
                }
                else
                {
                    itemAdress = Helpers.AccessControl.AppendAccessRightsCode(itemAdress);
                    theModel   = new ItemViewerModel(rqitemId, "http://mydocs.strands.de/" + itemAdress);
                }
                ViewBag.DocAdr = (theModel.Count() > 0) ? theModel.itemAdress : "UNDEFINED";
                return(View(theModel));
            }
            else if (itemAdress.StartsWith("MyMusic"))
            {
                AudioModel theModel;

                if ((System.Web.HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST").ToLower() == "localhost") || (System.Web.HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST").ToLower() == "admin-pc"))
                {
                    theModel = new AudioModel(rqitemId, "http://" + System.Web.HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST") + "/" + itemAdress);
                }
                else
                {
                    //Access to remote document server & access control not yet implemented
                    //itemAdress = Helpers.AccessControl.AppendAccessRightsCode(itemAdress);
                    theModel = new AudioModel(rqitemId, "http://mydocs.strands.de/" + itemAdress);
                }
                ViewBag.DocAdr = theModel.Count() == 1 ? theModel.PlayList.Tracks[0].mp3 : (theModel.Count() > 0 ? "PLAYLIST" : "UNDEFINED");
                return(View("AudioPlayer", theModel));
            }
            else
            {
                string     fullAdress = "http://" + System.Web.HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST") + "/" + itemAdress + (itemAdress.EndsWith(".m4v") ? "" : "/" + itemAdress.Substring(itemAdress.LastIndexOf("/") + 1) + ".m4v");
                VideoModel theModel   = new VideoModel(rqitemId, fullAdress);

                ViewBag.DocAdr = (theModel.Count() > 0) ? theModel.itemAdress : "UNDEFINED";
                return(View("VideoPlayer", theModel));
            }
        }
        protected override void Awake()
        {
            audioModel = Models.GetModel <AudioModel>();

            if (audioModel != null)
            {
                for (int i = 0; i < soundClips.Length; ++i)
                {
                    audioModel.AddSound(soundClips[i].name, soundClips[i]);
                }

                for (int i = 0; i < musicClips.Length; ++i)
                {
                    audioModel.AddMusic(musicClips[i].name, musicClips[i]);
                }
            }
        }
        public ActionResult UploadAudio(Guid bandId)
        {
            var file     = Request.Files[0];
            var filename = HttpContext.SaveAudio(file);

            var audio = new AudioModel
            {
                AudioID = Guid.NewGuid(),
                Title   = filename,
                BandID  = bandId,
                Url     = filename
            };

            DataRepository.AddAudio(audio);

            return(Json(new { success = true }));
        }
        private void TeamplatesDictonary_AudioAddToPlaylist(AudioModel audioModel)
        {
            SelectPlaylistPage selectPlaylistPage = new SelectPlaylistPage();

            selectPlaylistPage.ExitButton.Click += delegate(object sender, RoutedEventArgs e){
                AuthFrame.Visibility = Visibility.Collapsed;
                AuthFrame.Content    = null;
                selectPlaylistPage   = null;
            };
            selectPlaylistPage.AlbumSelectedEvent += delegate(AlbumModel AlbumModel)
            {
                AuthFrame.Visibility = Visibility.Collapsed;
                var Awaiter = Tools.VkApi.Audio.AddToPlaylistAsync(AlbumModel.OwnerID, AlbumModel.ID,
                                                                   new string[] { audioModel.Owner_ID + "_" + audioModel.ID.ToString() + "_" + audioModel.AccessKey });
            };
            AuthFrame.Content    = selectPlaylistPage.Content;
            AuthFrame.Visibility = Visibility.Visible;
        }
Exemple #21
0
        /// <summary>
        /// Index Action.
        /// </summary>
        /// <returns>View</returns>
        public ActionResult Index()
        {
            var audioModel = new AudioModel()
            {
                Zones  = new List <Zone>(this.amplifier.GetZones()),
                Inputs = new List <Input>(this.amplifier.GetInputs())
            };

            foreach (var zone in audioModel.Zones)
            {
                zone.FriendlyName = ConfigurationManager.AppSettings.Get(string.Format("Zone.FriendlyName.{0}", zone.Id)) ?? zone.Id;
            }

            var zoneOrders = ConfigurationManager.AppSettings.Get("Zone.Order");

            if (!string.IsNullOrEmpty(zoneOrders))
            {
                var zoneOrdersNumber = zoneOrders.Split(',');
                audioModel.Zones.Sort((x, y) =>
                                      Array.FindIndex(zoneOrdersNumber, m => m == x.Id)
                                      <=
                                      Array.FindIndex(zoneOrdersNumber, m => m == y.Id) ?
                                      -1 : 1);
            }

            foreach (var input in audioModel.Inputs)
            {
                input.FriendlyName = ConfigurationManager.AppSettings.Get(string.Format("Input.FriendlyName.{0}", input.Id)) ?? input.Id;
            }

            var inputOrders = ConfigurationManager.AppSettings.Get("Input.Order");

            if (!string.IsNullOrEmpty(inputOrders))
            {
                var inputOrdersNumber = inputOrders.Split(',');
                audioModel.Inputs.Sort((x, y) =>
                                       Array.FindIndex(inputOrdersNumber, m => m == x.Id)
                                       <=
                                       Array.FindIndex(inputOrdersNumber, m => m == y.Id) ?
                                       -1 : 1);
            }

            return(this.View(audioModel));
        }
        private void ToolsAndsettings_ListClickHandlerCommonEvent(System.Collections.ObjectModel.ObservableCollection <AudioModel> model, int selectedIndex)
        {
            LoadingList = true;
            if (selectedIndex != -1)
            {
                SelectedIndex = selectedIndex;

                AudioModel[] AudiomodelArry = new AudioModel[model.Count];
                model.CopyTo(AudiomodelArry, 0);
                AudioCollection.Clear();
                foreach (var Audio in AudiomodelArry)
                {
                    AudioCollection.Add(Audio);
                }

                AudioListView.SelectedIndex = selectedIndex;
                AudioListView.ScrollIntoView(AudioCollection[SelectedIndex]);
            }
            LoadingList = false;
        }
        private void Player_updateAudioModel(AudioModel audioModel)
        {
            this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
            {
                PlayPauseTrackButton.Content     = System.Net.WebUtility.HtmlDecode("&#xE769;");
                PlayPouseThumbButton.ImageSource = Tools.LoadBitmapFromResource("Resources/pause.png");
                AudioPlayerTitle.Text            = audioModel.Title;
                AudioPlayerArtist.Text           = audioModel.Artist;
                if (audioModel.ImageUrl != null)
                {
                    AudioPlayerImage.ImageSource = new BitmapImage(new Uri(audioModel.ImageUrl));
                }
                else
                {
                    AudioPlayerImage.ImageSource = new BitmapImage(new Uri(@"pack://application:,,,/Resources/MusicIcon.jpg", UriKind.Absolute));
                }

                PlayerSlider.Maximum = audioModel.DurationSeconds;
            }));
        }
    {/// <summary>
     /// 获取所有麦克风设备(音频输入设备)
     /// </summary>
     /// <returns></returns>
        public static List <AudioModel> GetMicrophoneDevices()
        {
            var enumerator     = new MMDeviceEnumerator();
            var captureDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToArray();

            var microphoneList = new List <AudioModel>();

            if (captureDevices.Length > 0)
            {
                for (int i = 0; i < captureDevices.Length; i++)
                {
                    AudioModel microphone = new AudioModel
                    {
                        id   = (i + 1).ToString(),
                        name = captureDevices[i].FriendlyName
                    };
                    microphoneList.Add(microphone);
                }
            }
            return(microphoneList);
        }
        public static List <AudioModel> GetMicrophoneDevices2()
        {
            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.AudioInputDevice);
            var microphoneList = new List <AudioModel>();

            if (videoDevices.Count > 0)
            {
                for (int i = 0; i < videoDevices.Count; i++)
                {
                    if (videoDevices[i].Name != "virtual-audio-capturer")
                    {
                        AudioModel microphone = new AudioModel
                        {
                            id   = (i + 1).ToString(),
                            name = videoDevices[i].Name
                        };
                        microphoneList.Add(microphone);
                    }
                }
            }
            return(microphoneList);
        }
Exemple #26
0
        private void btnClassificar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtArquivoAudio.Text) || !File.Exists(txtArquivoAudio.Text))
            {
                return;
            }


            txtResultado.Text = string.Empty;

            var cronometro = new Stopwatch();

            cronometro.Start();

            var core = new SpeechCore();

            foreach (var modelo in SpeechConfig.Instance.Modelos)
            {
                var audioModel = new AudioModel(modelo.Arquivos.ToArray());
                audioModel.Descricao = modelo.Nome;
                core.AdicionarModelo(audioModel);
            }

            core.Treinar();

            cronometro.Stop();

            WriteLine($"Tempo de treinamento: {cronometro.Elapsed}");

            cronometro.Reset();
            cronometro.Start();
            core.Classificar(txtArquivoAudio.Text, WriteLine, Write);

            cronometro.Stop();

            WriteLine($"Tempo de classificação: {cronometro.Elapsed}");
        }
        private void Add(AudioModel audioModel, bool isMyAudio)
        {
            ObservableCollection <AudioItemViewModel> _item = new ObservableCollection <AudioItemViewModel>();

            foreach (var item in audioModel.response.items)
            {
                var itemAudio = new AudioItemViewModel(_vkApi, _flyout)
                {
                    Id       = item.id,
                    OwnerId  = item.owner_id,
                    IsMyItem = isMyAudio,
                    Url      = item.url,
                    Title    = item.title,
                    Duration = item.duration,
                    Artist   = item.artist,
                    LyricsId = item.lyrics_id,
                    GenreId  = item.genre_id,
                    NoSearch = item.no_search
                };

                _item.Add(itemAudio);
            }
            AudioItemsViewModel = _item;
        }
Exemple #28
0
 public AudioItemModel(bool v, AudioModel parent)
 {
     IsDesktop = v;
     Parent    = parent;
 }
Exemple #29
0
        void Start()
        {
            AudioModel model = new AudioModel();

            clip = model.GetList(collection);
        }
 public IActionResult Index(AudioModel model)
 {
     model.path = "https://highchurch.space/Assets/Audio/test.mp3";
     model.set_html();
     return(View("Index", model));
 }
Exemple #31
0
 public static IEnumerable <double[]> ObterCaracteristicas(this AudioModel audioModel, int msSegmentos) => audioModel.Audios.SelectMany(a => ObterCaracteristicas(a, msSegmentos));