Merge branch 'pr-2548-multistream-master'

This commit is contained in:
Reuben Morais 2020-01-18 12:41:48 +01:00
Родитель e04730c180 92fff3b612
Коммит b4e3853064
2 изменённых файлов: 16 добавлений и 9 удалений

Просмотреть файл

@ -18,20 +18,20 @@ namespace DeepSpeechWPF
const int BEAM_WIDTH = 500;
//Register instance of DeepSpeech
DeepSpeechClient.DeepSpeech deepSpeechClient = new DeepSpeechClient.DeepSpeech();
try
{
deepSpeechClient.CreateModel("output_graph.pbmm", BEAM_WIDTH);
//Register instance of DeepSpeech
DeepSpeechClient.DeepSpeech deepSpeechClient =
new DeepSpeechClient.DeepSpeech("output_graph.pbmm", BEAM_WIDTH);
SimpleIoc.Default.Register<IDeepSpeech>(() => deepSpeechClient);
SimpleIoc.Default.Register<MainWindowViewModel>();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
Current.Shutdown();
}
SimpleIoc.Default.Register<IDeepSpeech>(() => deepSpeechClient);
SimpleIoc.Default.Register<MainWindowViewModel>();
}
protected override void OnExit(ExitEventArgs e)

Просмотреть файл

@ -4,6 +4,7 @@ using CSCore.CoreAudioAPI;
using CSCore.SoundIn;
using CSCore.Streams;
using DeepSpeechClient.Interfaces;
using DeepSpeechClient.Models;
using GalaSoft.MvvmLight.CommandWpf;
using Microsoft.Win32;
using System;
@ -58,6 +59,12 @@ namespace DeepSpeech.WPF.ViewModels
#endregion
#region Streaming
/// <summary>
/// Stream used to feed data into the acoustic model.
/// </summary>
private DeepSpeechStream _sttStream;
/// <summary>
/// Records the audio of the selected device.
/// </summary>
@ -308,7 +315,7 @@ namespace DeepSpeech.WPF.ViewModels
if (_bufferQueue.TryDequeue(out short[] buffer))
{
StreamingIsBusy = true;
_sttClient.FeedAudioContent(buffer, Convert.ToUInt32(buffer.Length));
_sttClient.FeedAudioContent(_sttStream, buffer, Convert.ToUInt32(buffer.Length));
StreamingIsBusy = false;
}
}
@ -386,7 +393,7 @@ namespace DeepSpeech.WPF.ViewModels
{
await Task.Delay(90);
}
Transcription = _sttClient.FinishStream();
Transcription = _sttClient.FinishStream(_sttStream);
EnableStartRecord = true;
}
@ -395,7 +402,7 @@ namespace DeepSpeech.WPF.ViewModels
/// </summary>
private void StartRecording()
{
_sttClient.CreateStream();
_sttStream =_sttClient.CreateStream();
_audioCapture.Start();
EnableStartRecord = false;
EnableStopRecord = true;