Esempio n. 1
0
 public void Cadastrar(Sfs Lancamento)
 {
     using (OpFlixContext ctx = new OpFlixContext())
     {
         ctx.Sfs.Add(Lancamento);
         ctx.SaveChanges();
     }
 }
 public IActionResult Atualizar(int id, Sfs lancamento)
 {
     try
     {
         lancamento.IdSf = id;
         lancamentoRepository.Atualizar(lancamento);
         return(Ok());
     } catch
     {
         return(BadRequest());
     }
 }
 public IActionResult Cadastrar(Sfs lancamento)
 {
     try
     {
         lancamentoRepository.Cadastrar(lancamento);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
Esempio n. 4
0
 public void Atualizar(Sfs Lancamento)
 {
     using (OpFlixContext ctx = new OpFlixContext())
     {
         Sfs sfBuscado = ctx.Sfs.Find(Lancamento.IdSf);
         sfBuscado.Titulo      = Lancamento.Titulo;
         sfBuscado.Sinopse     = Lancamento.Sinopse;
         sfBuscado.TempoD      = Lancamento.TempoD;
         sfBuscado.IdCat       = Lancamento.IdCat;
         sfBuscado.IdTipo      = Lancamento.IdTipo;
         sfBuscado.FaixaEtaria = Lancamento.FaixaEtaria;
         sfBuscado.Descricao   = Lancamento.Descricao;
         sfBuscado.Plataforma  = Lancamento.Plataforma;
         ctx.Sfs.Update(sfBuscado);
         ctx.SaveChanges();
     }
 }
Esempio n. 5
0
        static void Main(string[] args)
        {
            try
            {
                SpVoice sapi = new SpVoice();
                SpObjectTokenCategory sapiCat = new SpObjectTokenCategory();
                Dictionary <string, SpObjectToken> TokerPool = new Dictionary <string, SpObjectToken>();
                SpFileStream Sfs = null;

                // See https://qiita.com/7shi/items/7781516d6746e29c03b4
                sapiCat.SetId(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCore\Voices", false);

                // Narrator voices
                foreach (SpObjectToken token in sapiCat.EnumerateTokens())
                {
                    if (!TokerPool.ContainsKey(token.GetAttribute("name")))
                    {
                        TokerPool.Add(token.GetAttribute("name"), token);
                    }
                }

                // SAPI voices
                foreach (SpObjectToken token in sapi.GetVoices("", ""))
                {
                    if (!TokerPool.ContainsKey(token.GetAttribute("name")))
                    {
                        TokerPool.Add(token.GetAttribute("name"), token);
                    }
                }

                SpeakerList = TokerPool.Select((val, idx) => new { Key = idx, Value = val.Value }).ToDictionary(s => s.Key, s => s.Value);

                if (!Opt(args))
                {
                    return;
                }

                if (file != "")
                {
                    Sfs = new SpFileStream();
                    Sfs.Open(file, SpeechStreamFileMode.SSFMCreateForWrite);
                    sapi.AudioOutputStream = Sfs;
                }

                Thread t = new Thread(() => {
                    SpObjectToken backupSapi = sapi.Voice;
                    sapi.Voice  = SpeakerList[AvatorIdx];
                    sapi.Rate   = Speed;
                    sapi.Volume = Volume;
                    sapi.Speak(text);
                    sapi.Voice = backupSapi;
                });
                t.SetApartmentState(ApartmentState.STA);
                t.Start();
                t.Join();

                if (file != "")
                {
                    Sfs.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("err:{0},{1}", e.Message, e.InnerException == null ? "" : e.InnerException.Message);
            }
        }