Share via


TtsEngineSsml.GetOutputFormat(SpeakOutputFormat, IntPtr) Methode

Definition

Gibt die am besten passende Audioausgabe zurück, die von einer Antwort die angegebene Synthetisier-Engine auf eine Anforderung an die Synthetisier-Engine für die Unterstützung eines bestimmten Ausgabeformats unterstützt wird.

public:
 abstract IntPtr GetOutputFormat(System::Speech::Synthesis::TtsEngine::SpeakOutputFormat speakOutputFormat, IntPtr targetWaveFormat);
public abstract IntPtr GetOutputFormat (System.Speech.Synthesis.TtsEngine.SpeakOutputFormat speakOutputFormat, IntPtr targetWaveFormat);
abstract member GetOutputFormat : System.Speech.Synthesis.TtsEngine.SpeakOutputFormat * nativeint -> nativeint
Public MustOverride Function GetOutputFormat (speakOutputFormat As SpeakOutputFormat, targetWaveFormat As IntPtr) As IntPtr

Parameter

speakOutputFormat
SpeakOutputFormat

Gültiger Member der SpeakOutputFormat-Enumeration, der den Typ des angeforderten Audioausgabeformats angibt.

targetWaveFormat
IntPtr

nativeint

Ein Zeiger auf struct, das Detaileinstellung für den Audioformattyp enthält, der vom speakOutputFormat-Argument angefordert wurde.

Gibt zurück

IntPtr

nativeint

Gibt eine gültige IntPtr-Instanz zurück, die auf ein struct verweist, das ausführliche Informationen über das Ausgabeformat enthält.

Beispiele

Die folgende Beispielimplementierung überprüft ausgewählte Eingaben und verwendet sie, wenn sie sich innerhalb der Toleranzen befinden, andernfalls mit Standardwerten.

public IntPtr GetOutputFormat(SpeakOutputFormat format, IntPtr targetWaveFormat) {  
    WaveFormat waveFormat = new WaveFormat();  
    WaveFormat rq=new WaveFormat();  
    Marshal.PtrToStructure(targetWaveFormat,rq);  

    waveFormat.AvgBytesPerSec = AvgBytesPerSec Min < rq.AvgBytesPerSec && rq.AvgBytesPerSec < AvgBytesPerSecMax? rq.AvgBytesPerSec : 3200;  
    waveFormat.BitsPerSample = BitsPerSampleMin < rq.AvgBytesPerSec && rq.BitsPerSample < BitsPerSampleMax ? rq.AvgBytesPerSec : 3200; 16;  
    waveFormat.BlockAlign = 2;  
    waveFormat.Channels = 1;  
    waveFormat.FormatTag = 1;  
    waveFormat.SamplesPerSec = 16000;  
    waveFormat.Size = 0;  

    IntPtr wfx = Marshal.AllocCoTaskMem(Marshal.SizeOf(waveFormat));  
    Marshal.StructureToPtr(waveFormat, wfx, false);  

    //Console.WriteLine ("GetOutputFormat called");  
    return wfx;  
}  
internal struct WaveFormat {  
    public Int16 FormatTag;  
    public Int16 Channels;  
    public int SamplesPerSec;  
    public int AvgBytesPerSec;  
    public Int16 BlockAlign;  
    public Int16 BitsPerSample;  
    public Int16 Size;  
}  

Hinweise

Die als targetWaveFormat und von der -Methode zurückgegebene Struktur sollte mit dem WAVEFORMATEX unter SAPI verfügbaren kompatibel sein, und der zurückgegebene Wert sollte mithilfe CoTaskMemAllocvon zugeordnet werden.

Die struct muss Funktionen bereitstellen, die folgendes äquivalent sind:

internal struct WaveFormat  
{  
    public Int16 FormatTag;  
    public Int16 Channels;  
    public int SamplesPerSec;  
    public int AvgBytesPerSec;  
    public Int16 BlockAlign;  
    public Int16 BitsPerSample;  
    public Int16 Size;  
}  

Hinweise für Ausführende

Ein Objekt, das von TtsEngineSsml erbt, sollte das angeforderte Ausgabeformat untersuchen, wie von targetWaveFormat angegeben, und das nächste Format zurückgeben, das es unterstützt.

Gilt für: