Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

FilePrompt Constructor (String, SynthesisMediaType)

Creates a new instance of the FilePrompt class, specifying the path to the file and its media type.

Namespace:  Microsoft.Speech.Synthesis
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public Sub New ( _
    path As String, _
    media As SynthesisMediaType _
)
'Usage
Dim path As String
Dim media As SynthesisMediaType

Dim instance As New FilePrompt(path, media)
public FilePrompt(
    string path,
    SynthesisMediaType media
)

Parameters

  • path
    Type: System.String
    The path of the file containing the prompt content.

Remarks

You can use this class to create an object from an existing Speech Synthesis Markup Language (SSML) file that the SpeechSynthesizer can consume to generate speech.

Examples

The example that follows creates a FilePrompt object that specifies a path to an SSML prompt. To speak the contents of the prompt, the example then provides the FilePrompt object as the argument to the Speak(Prompt) method.

using System;
using Microsoft.Speech.Synthesis;

namespace SampleSynthesis
{
  class Program
  {
    static void Main(string[] args)
    {

      // Initialize a new instance of the SpeechSynthesizer.
      using (SpeechSynthesizer synth = new SpeechSynthesizer())
      {

        // Configure the audio output. 
        synth.SetOutputToWaveFile(@"C:\test\FilePrompt.wav");

        // Create a SoundPlayer instance to play the output audio file.
        System.Media.SoundPlayer m_SoundPlayer =
          new System.Media.SoundPlayer(@"C:\test\FilePrompt.wav");

        // Create a FilePrompt object that references an SSML prompt.
        FilePrompt ssmlFile = new FilePrompt("c:\\test\\Weather.ssml", SynthesisMediaType.Ssml);

        // Speak the prompt and play back the output file.
        synth.Speak(ssmlFile);
        m_SoundPlayer.Play();
      }

      Console.WriteLine();
      Console.WriteLine("Press any key to exit...");
      Console.ReadKey();
    }
  }
}

The following is the SSML file that the preceding example references.

<?xml version="1.0" encoding="ISO-8859-1"?>
<speak version="1.0"
 xmlns="http://www.w3.org/2001/10/synthesis"
 xml:lang="en-US">

  <s> The weather forecast for today is partly cloudy with some sun breaks. </s>

</speak>

See Also

Reference

FilePrompt Class

FilePrompt Members

FilePrompt Overload

Microsoft.Speech.Synthesis Namespace