Shell is a collection of utility libraries for interactive command lines, whether they run as console applications or chatbots, use text output or speech.
Installation
You can install the Shell libraries via NuGet.
To build Shell from source you will need an F# 7.0 compiler (or newer) and a .NET development environment. The .sln
and .fsproj
files in the source directories should be understood by .NET SDK command line tools, or IDEs such as VSCode, VisualStudio, or Rider.
Shell.Speech
Usage
Here's a brief example for using the Shell.Speech library:
#r "nuget: Murphy.Shell.Speech, 1.0.2.*"
open System
open Murphy.Shell.Speech
ISpeechSynthesizer.SetDllImportResolver()
let speech = ISpeechSynthesizer.CreateDefault()
speech.SelectVoice(culture = Globalization.CultureInfo.GetCultureInfo("en-US"))
speech.Speak("Hello world! How are you?")
speech.Dispose()
The call ISpeechSynthesizer.CreateDefault()
creates a wrapper around the System.Speech.Synthesis
API, if the platform supports it (i.e. on modern Windows), and falls back to eSpeak (NG) otherwise.
For the eSpeak (NG) wrapper to work, the corresponding native library needs to be installed. On Ubuntu Linux, for example, you could install the libespeak-ng1
or libespeak1
packages to satisfy the dependency. The location of eSpeak (NG) data files may be specified in the environment variable ESPEAK_DATA
to override the library's default path.
Extra Code
The call ISpeechSynthesizer.SetDllImportResolver()
is supported by extra code that relies on APIs not found in netstandard2.0
. In addition to the obvious
<PackageReference Include="Murphy.Shell.Speech" Version="1.0.2.*" />
include
<Compile Include="$(ShellSpeechExtra)\SpeechLibraryLoader.fs" />
in your project file and save the effort of writing suitable native library loading logic yourself.
License
Shell is licensed under the Apache License, Version 2.0. Refer to the NOTICE for licenses of third-party dependencies.