Exemplo n.º 1
0
        public async Task <ActionResult <IEnumerable <Clips> > > PostClips(AddClip newClip)
        {
            string userId = getCustomerId();
            string id     = Guid.NewGuid().ToString();
            Clips  clips  = new Clips(userId, newClip, id);

            // clips.id

            _context.Clips.Add(clips);
            await _context.SaveChangesAsync();

            // return CreatedAtAction("GetClips", new { userId = clips.userid }, clips);
            List <Clips> myClips = await _context.Clips.ToListAsync();

            myClips = myClips.Where(item => item.userid == userId).ToList();
            return(myClips);
        }
Exemplo n.º 2
0
        public MainWindowViewModel()
        {
            StartCapture = new ReactiveCommand();
            StartCapture.Subscribe(() =>
            {
                if (CreateCaptureItemForWindow(SelectedWindow.Value.Hwnd, out var result))
                {
                    var item = (GraphicsCaptureItem)Marshal.GetObjectForIUnknown(result);
                    CurrentGraphicsCaptureItem.Value = item;
                    util.StartCaptureInternal(item);
                }
            });

            AddClip.Subscribe(() =>
            {
                if (util == null)
                {
                    return;
                }
                var clip = new App1.ClipImage();
                var vm   = new ClipImageViewModel(clip);
                var co   = new App1.ClipImageConteir(clip);
                util.ClipImages.Add(clip, co);
                ClipImages.Add(vm);
                CreateRecogStream();
            });
            RemoveClip.Subscribe(vm =>
            {
                if (vm == null)
                {
                    return;
                }
                if (util != null)
                {
                    var co = util.ClipImages.GetValueOrDefault(vm.ClipImage);
                    util.ClipImages.Remove(vm.ClipImage);
                    co.Dispose();
                }
                if (SelectedClipImage.Value == vm)
                {
                    SelectedClipImage.Value = null;
                }
                ClipImages.Remove(vm);
                CreateRecogStream();
            });
            ScriptReslut = Observable.CombineLatest(Script, RecognizedText.Pairwise(), (script, pair) => (script, pair)).SelectMany(async scriptData =>
            {
                try
                {
                    var state = await CSharpScript.RunAsync <ScriptResult>(scriptData.script, globals: new ScriptModel(scriptData.pair.OldItem, scriptData.pair.NewItem));
                    return(state.ReturnValue);
                }
                catch (Exception e)
                {
                    return(new ScriptResult
                    {
                        IsRead = false,
                        Text = e.ToString()
                    });
                }
            }
                                                                                                                                    ).ToReadOnlyReactiveProperty();

            ScriptReslut.Where(result => result != null).Where(result => !string.IsNullOrWhiteSpace(result.Text)).Where(result => result.IsRead).Select(result => result.Text).Distinct().Subscribe(async text =>
            {
                if (!Reading.Value)
                {
                    return;
                }
                var json = System.Text.Json.JsonSerializer.Serialize(new VoiceloidParam
                {
                    Effects = new VoiceloidEffects
                    {
                        Volume     = Volume.Value,
                        Speed      = Speed.Value,
                        Pitch      = Pitch.Value,
                        Intonation = Intonation.Value
                    },
                    Talktext = text
                },
                                                                     new System.Text.Json.JsonSerializerOptions {
                    PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase
                });
                var content = new StringContent(json, Encoding.UTF8, @"application/json");
                try
                {
                    await httpClient.PostAsync("http://localhost:7180//PLAY2/1700", content);
                }
                catch { }
            });

            var byteArray = Encoding.ASCII.GetBytes(string.Format("{0}:{1}", "SeikaServerUser", "SeikaServerPassword"));

            httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
            RefreshWindow.Subscribe(() => RefreshWindows());
            RefreshWindows();
        }