私はWindows.Media.SpeechSynthesisクラスでアプリケーションが最初の文字列を合成するという、この単純なコードをC#UWPに入れています。最初の合成が終了した後の文字列。私は、文字列1 + str2のを含めるだけの文字列を作ることでそれが可能だ知っているが、このコードを実行するシナリオはより複雑であり、これは、それは不可能です。いつものように(英語の私の低レベルのために申し訳ありません)どのように私は非同期関数の終わりに関数を開始するのですか?C#UWP
public MainPage()
{
this.InitializeComponent();
string str1 = "weather data";
talk(Textmeteo);
string str2 = "hello world";
talk(str2);
}
public async void talk(string text)
{
// The media object for controlling and playing audio.
MediaElement mediaElement = new MediaElement();
// The object for controlling the speech synthesis engine (voice).
SpeechSynthesizer synth = new SpeechSynthesizer();
// Generate the audio stream from plain text.
SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(text);
// Send the stream to the media object.
mediaElement.SetSource(stream, stream.ContentType);
mediaElement.Play();
}
なぜあなたのシナリオでは 'str1 + str2'はできませんか? – AVK
@AVK str1が合成されている最初のシナリオでは、str2を構成するデータをオンラインで読むためにhttp要求が実行されるためです。 2番目のシナリオでは、私は音声認識を開始するために、最初にsynthetizeの最後を指すデータが必要です。 –