void srvc_SpeakCompleted(object sender, ServiceReference1.SpeakCompletedEventArgs e) { if (e.Error == null) { this.SpeakFileUrl = new Uri(e.Result); WebClient client = new WebClient(); client.OpenReadCompleted += ((s, args) => { using (var isoStream = new IsolatedStorageFileStream(SpeakFileName, FileMode.Create, IsolatedStorageFile.GetUserStoreForApplication())) { byte[] bs = new byte[args.Result.Length]; args.Result.Read(bs, 0, bs.Length); isoStream.Write(bs, 0, bs.Length); isoStream.Flush(); this.CanSpeak = true; } }); client.OpenReadAsync(this.SpeakFileUrl); } else { throw e.Error; } }
void translator_SpeakCompleted(object sender, ServiceReference1.SpeakCompletedEventArgs e) { this.SpeakProgress.Visibility = Visibility.Collapsed; RecognizingProgress.Visibility = Visibility.Collapsed; var client = new WebClient(); client.OpenReadCompleted += ((s, args) => { SoundEffect se = SoundEffect.FromStream(args.Result); SoundEffect.MasterVolume = 0.8f; se.Play(); }); client.OpenReadAsync(new Uri(e.Result)); }