/// <summary> /// 棒読みちゃんで読み上げ /// </summary> private void Bouyomi(string text) { var bouyomiChanClient = new BouyomiChanClient(); bouyomiChanClient.AddTalkTask(text); bouyomiChanClient.Dispose(); }
private void FormTest_FormClosed(object sender, FormClosedEventArgs e) { //タイマ停止 timerCheck.Stop(); //棒読みちゃんへの接続を解除 BouyomiChan.Dispose(); }
/// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param> protected virtual void Dispose(bool disposing) { if (!disposed) { // 棒読みちゃんクライアント破棄処理 if (bouyomiChanClient != null) { bouyomiChanClient.Dispose(); bouyomiChanClient = null; } disposed = true; } }
public void Dispose() { IsDisposed = true; try { Client.Dispose(); // ↑でエラーが起きると棒読みちゃんが残ったままになるが、手動で落とせるしまぁいいだろう。。。 BouyomiChanShutdown(); } catch (Exception ex) { Logger.Instance.PutMessage($"棒読みちゃん終了エラー: {ex.Message}"); } }
public void close() { bcc.Dispose(); }
private async void RecognizeButton_Click(object sender, RoutedEventArgs e) { await changeStateRecognizeButton(false); if (isListening == false) { if (audioConfig == null) { audioConfig = AudioConfig.FromDefaultMicrophoneInput(); } await changeControls(false); try { string subscriptionKey = AzureSubscriptionKeyTextBox.Text.Trim(); Uri endpointUri = new Uri(AzureServiceEndpointUriTextBox.Text.Trim()); if (subscriptionKey.Length == 0 || endpointUri.IsWellFormedOriginalString() != true) { await changeStateRecognizeButton(true); await changeControls(true); return; } textQueue = new ConcurrentQueue <string>(); speechConfig = SpeechConfig.FromEndpoint(endpointUri, subscriptionKey); speechConfig.SpeechRecognitionLanguage = "ja-JP"; recognizer = new SpeechRecognizer(speechConfig, audioConfig); if (bouyomiChan != null) { bouyomiChan.Dispose(); bouyomiChan = null; } if (BouyomiChanCheckBox.IsChecked == true) { bouyomiChan = new BouyomiChanClient(); } isListening = true; recognizer.Recognized += UpdateRecognizedText; recognizer.Canceled += RecognizeCanceled; await recognizer.StartContinuousRecognitionAsync(); double refreshSecond = RefreshSecondSlider.Value; _ = Task.Run(() => writeToTextfile(refreshSecond)); } catch (Exception ex) { Debug.WriteLine(ex.Message); if (bouyomiChan != null) { bouyomiChan.Dispose(); bouyomiChan = null; } await changeControls(true); await changeStateRecognizeButton(true); return; } } else { recognizer.Recognized -= UpdateRecognizedText; recognizer.Canceled -= RecognizeCanceled; await recognizer.StopContinuousRecognitionAsync(); if (bouyomiChan != null) { bouyomiChan.Dispose(); bouyomiChan = null; } isListening = false; await changeControls(true); } await changeStateRecognizeButton(true); }