static public SpeechProcessor GetInstance() { if (instance == null) instance = new SpeechProcessor(); return instance; }
public void Init(IModuleConfig config) { giftCacheManager = new GiftCacheManager(5); giftCacheManager.CacheExpired += GiftCacheManager_CacheExpired; speechProcessor = new SpeechProcessor(); speechProcessor.QueueChanged += Synthesizer_QueueChanged; DanmakuSpeechConfig speechConfig = (DanmakuSpeechConfig)config; OptionDict = speechConfig.OptionDict; SetVolume(speechConfig.Volume); Control = new DanmakuSpeechControl(this, speechConfig.OutputDevice); FileInfo fileInfo = new FileInfo("./config/speech.xml"); Stream speechConfigStream = null; try { if (fileInfo.Exists) { speechConfigStream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read); } else { speechConfigStream = Application.GetResourceStream(new Uri("Config/Speech.xml", UriKind.RelativeOrAbsolute)).Stream; } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(speechConfigStream); XmlNode enableAttr = xmlDocument.SelectSingleNode("speech/@enable"); string enable = enableAttr != null ? enableAttr.Value : "true"; if (enable.ToLower() != "false") { XmlNode tokenEndpointNode = xmlDocument.SelectSingleNode("speech/token_endpoint/text()"); XmlNode ttsEndpointNode = xmlDocument.SelectSingleNode("speech/tts_endpoint/text()"); XmlNode apiKeyNode = xmlDocument.SelectSingleNode("speech/api_key/text()"); string tokenEndpoint = tokenEndpointNode.Value; string ttsEndpoint = ttsEndpointNode.Value; string apiKey = apiKeyNode.Value; speechProcessor.Init(tokenEndpoint, ttsEndpoint, apiKey); } } catch (Exception ex) { Console.WriteLine(ex); } finally { if (speechConfigStream != null) { speechConfigStream.Close(); } } }
public SpeechProcessorShould() { IEosService eosService = GetMockService(); var groupToken = new GroupToken(eosService); speechProcessor = new SpeechProcessor(null); speechProcessor.Commands.Add(new NumberToken()); speechProcessor.Commands.Add(groupToken); speechProcessor.Commands.Add(new WordToken("GO")); speechProcessor.Commands.Add(new WordToken("THRU", "through")); speechProcessor.Commands.Add(new WordToken("@", "at")); }
private void button1_Click_1(object sender, EventArgs e) { List <String> articles = new List <string>(); articles.Add("The dog barks at night."); articles.Add("University of Johannesburg has been closed down."); articles.Add("Political struggles in johhaneburg."); articles.Add("Sharks won the tournament, they beat bluelions in a tough match."); //File.ReadAllText(@"C:\hypai\hyp_connect\App_Data\Reports\bbc\business\001.txt") foreach (var s in articles) { SpeechProcessor.ConvertToAudio(s, KeyGenerator.GetUniqueKey(10)); } String report = NewsComposer.createReportAudio(); NewsComposer.clearCache(); // Create a SoundPlayer instance to play output audio file. //System.Media.SoundPlayer m_SoundPlayer = // new System.Media.SoundPlayer(@"C:\hypai\hyp_connect\App_Data\test.wav"); //m_SoundPlayer.Play(); }
public MainWindow() { InitializeComponent(); CommandHandler = new CommandHandler(); SpeechProcessor = new SpeechProcessor(); }
public AdvertsAudioToText() { pr = new SpeechProcessor(); }
public Runner() { commandHandler = new CommandHandler(); speechProcessor = new SpeechProcessor(); }
static Program() { commandHandler = new CommandHandler(); speechProcessor = new SpeechProcessor(); }