Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. using System;
  2. using Windows;
  3.  
  4. namespace SampleSynthesis {
  5. class Program {
  6. static async System.Threading.Tasks.Task Main(string[] args) {
  7.  
  8. var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
  9. Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream =
  10. await synth.SynthesizeTextToStreamAsync("I want to listen to this text");
  11.  
  12. using (var reader = new Windows.Storage.Streams.DataReader(stream)) {
  13. await reader.LoadAsync((uint)stream.Size);
  14. Windows.Storage.Streams.IBuffer buffer = reader.ReadBuffer((uint)stream.Size);
  15. Windows.Storage.StorageFile file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("audio.wav");
  16. await Windows.Storage.FileIO.WriteBufferAsync(file, buffer);
  17. }
  18. }
  19. }
  20.  
  21. "C:Program Files (x86)Microsoft Visual Studio2019BuildToolsMSBuildCurrentBinRoslyncsc.exe" /r:"C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5.2System.Speech.dll","C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETCorev4.5System.Runtime.WindowsRuntime.dll","C:WindowsMicrosoft.NETFramework64v4.0.30319System.runtime.dll","C:Program Files (x86)Windows Kits10UnionMetadata10.0.17763.0Windows.winmd","C:WindowsMicrosoft.NETFramework64v4.0.30319System.Threading.Tasks.dll" tts.cs
  22.  
  23. Unhandled Exception: System.InvalidOperationException: The process has no package identity. (Exception from HRESULT: 0x80073D54)
  24. at Windows.Storage.ApplicationData.get_Current()
  25. at SampleSynthesis.Program.<Main>d__0.MoveNext()
  26. --- End of stack trace from previous location where exception was thrown ---
  27. at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  28. at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  29. at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
  30. at SampleSynthesis.Program.<Main>(String[] args)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement