Språk

TtsEngineSsml.GetOutputFormat(SpeakOutputFormat, IntPtr) Metod

Definition

Returnerar bästa matchande ljudutdata som stöds av ett givet syntetmotorsvar på en begäran till synthesizermotorn för stöd för ett visst utdataformat.

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

Parametrar

speakOutputFormat
SpeakOutputFormat

Giltig medlem i SpeakOutputFormat uppräkningen som anger typen av begärt ljudutdataformat.

targetWaveFormat
IntPtr

nativeint

En pekare till en struct innehållande detaljinställning för ljudformattypen som begärdes av speakOutputFormat argumentet.

Returer

IntPtr

nativeint

Returnerar en giltig IntPtr instans som refererar till en struct som innehåller detaljerad information om utdataformatet.

Exempel

Exempelimplementeringen nedan validerar valda indata med hjälp av dem om de ligger inom toleranser, annars med standardvärden.

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;
}

Kommentarer

Den struktur som används som targetWaveFormat och returneras av metoden bör vara kompatibel med den WAVEFORMATEX tillgängliga under SAPI och det returnerade värdet ska allokeras med .CoTaskMemAlloc

struct Måste tillhandahålla funktioner som motsvarar:

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

Anteckningar till implementerare

Objekt som ärver från TtsEngineSsml bör undersöka det begärda utdataformatet som anges av targetWaveFormat och returnera det närmaste format som det stöder.

Gäller för