1

The dll's for builtin namespaces like System.Windows and installed packages like Speech.Synthesis.Core are not getting detected, even after them being available in the project.asset.json & .csproj files.

The solutions provided in a similar question didn't work .
How else can this be resolved?

.csproj

  <ItemGroup>
    <PackageReference Include="Speech.Synthesis.Core" Version="0.1.0" />
  </ItemGroup>  

project.asset.json

{
  "version": 3,
  "targets": {
    ".NETCoreApp,Version=v3.0": {
      "Speech.Synthesis.Core/0.1.0": {
        "type": "package",
        "compile": {
          "lib/netstandard2.0/Speech.Synthesis.Core.dll": {}
        },
        "runtime": {
          "lib/netstandard2.0/Speech.Synthesis.Core.dll": {}
        }
      }
    }
  },
  "libraries": {
    "Speech.Synthesis.Core/0.1.0": {
      "sha512": "Private key",
      "type": "package",
      "path": "speech.synthesis.core/0.1.0",
      "files": [
        ".nupkg.metadata",
        ".signature.p7s",
        "lib/netstandard2.0/Speech.Synthesis.Core.dll",
        "speech.synthesis.core.0.1.0.nupkg.sha512",
        "speech.synthesis.core.nuspec"
      ]
    }
  },
  "projectFileDependencyGroups": {
    ".NETCoreApp,Version=v3.0": [
      "Speech.Synthesis.Core >= 0.1.0"
    ]
  },
  "packageFolders": {
    "C:\\Users\\User0\\.nuget\\packages\\": {}
  },
  "project": {
    "version": "1.0.0",
    "restore": {
      "projectUniqueName": "F:\\Script\\cs\\VsCode\\Windows\\Windows.csproj",
      "projectName": "Windows",
      "projectPath": "F:\\Script\\cs\\VsCode\\Windows\\Windows.csproj",
      "packagesPath": "C:\\Users\\User0\\.nuget\\packages\\",
      "outputPath": "F:\\Script\\cs\\VsCode\\Windows\\obj\\",
      "projectStyle": "PackageReference",
      "configFilePaths": [
        "C:\\Users\\User0\\AppData\\Roaming\\NuGet\\NuGet.Config"
      ],
      "originalTargetFrameworks": [
        "netcoreapp3.0"
      ],
      "sources": {
        "https://api.nuget.org/v3/index.json": {}
      },
      "frameworks": {
        "netcoreapp3.0": {
          "projectReferences": {}
        }
      },
      "warningProperties": {
        "warnAsError": [
          "NU1605"
        ]
      }
    },
    "frameworks": {
      "netcoreapp3.0": {
        "dependencies": {
          "Speech.Synthesis.Core": {
            "target": "Package",
            "version": "[0.1.0, )"
          }
        },
        "imports": [
          "net461",
          "net462",
          "net47",
          "net471",
          "net472",
          "net48"
        ],
        "assetTargetFallback": true,
        "warn": true,
        "frameworkReferences": {
          "Microsoft.NETCore.App": {
            "privateAssets": "all"
          }
        },
        "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.0.100-preview8-013656\\RuntimeIdentifierGraph.json"
      }
    }
  }
}

Error

 Program.cs(4,14): error CS0234: The type or namespace name 'Speech' does not exist in the namespace 'System' (are you missing an assembly reference?) [F:\Script\cs\VsCode\Windows\Windows.csproj] 
    Program.cs(10,37): error CS0246: The type or namespace name 'Window' could not be found (are you missing a using directive or an assembly reference?) [F:\Script\cs\VsCode\Windows\Windows.csproj] 
    Program.cs(21,49): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?) [F:\Script\cs\VsCode\Windows\Windows.csproj]

CODE

using System.Collections.Generic;
using System.Globalization;
using System.Windows;
using System.Speech.Synthesis;



namespace GuiTTS
{
  public partial class MainWindow : Window
  {
    private const string en = "en-US";
    private const string ru = "ru-RU";
    private readonly IDictionary<string, string> _messagesByCulture =
      new Dictionary<string, string>();
    public MainWindow()
    {
      InitializeComponent();
      PopulateMessages();
    }
    private void PromptInEnglish(object sender, RoutedEventArgs e)
    {
      DoPrompt(en);
    }
    private void PromptInRussian(object sender, RoutedEventArgs e)
    {
      DoPrompt(ru);
    }
    private void DoPrompt(string culture)
    {
      var synthesizer = new SpeechSynthesizer();
      synthesizer.SetOutputToDefaultAudioDevice();
      var builder = new PromptBuilder();
      builder.StartVoice(new CultureInfo(culture));
      builder.AppendText(_messagesByCulture[culture]);
      builder.EndVoice();
      synthesizer.Speak(builder);
    }
    private void PopulateMessages()
    {
      _messagesByCulture[en] = "For the connection flight 123 to Saint Petersburg, please, proceed to gate A1";
      _messagesByCulture[ru] ="Для пересадки на рейс 123 в  Санкт-Петербург, пожалуйста, пройдите к выходу A1";
    }
  }
}
srt111
  • 1,079
  • 11
  • 20

0 Answers0