Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

FilePrompt Constructor (String, SynthesisMediaType)

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

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

public FilePrompt(
	string path,
	SynthesisMediaType media
)

Parameters

path
Type: System.String

The path of the file containing the prompt content.

media
Type: System.Speech.Synthesis.SynthesisMediaType

The media type of the file.

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.

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 method.

using System;
using System.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.SetOutputToDefaultAudioDevice();

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

                // Speak the contents of the SSML prompt.
                synth.Speak(ssmlFile);
            }

            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>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4
Show:
© 2015 Microsoft