Win32 API 日本語リファレンス
ホームMedia.Speech › SPPHRASE

SPPHRASE

構造体
サイズx64: 176 バイト / x86: 128 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
BaseSPPHRASE_50160/120+0+0SAPI 5.0互換のフレーズ基本情報(SPPHRASE_50)。
pSMLLPWSTR8/4+160+120意味解釈結果を表すSML(XML)文字列へのポインタ。
pSemanticErrorInfoSPSEMANTICERRORINFO*8/4+168+124意味解釈で生じたエラー情報へのポインタ。無ければNULL。

各言語での定義

#include <windows.h>

// SPPHRASERULE  (x64 48 / x86 32 バイト)
typedef struct SPPHRASERULE {
    LPWSTR pszName;
    DWORD ulId;
    DWORD ulFirstElement;
    DWORD ulCountOfElements;
    SPPHRASERULE* pNextSibling;
    SPPHRASERULE* pFirstChild;
    FLOAT SREngineConfidence;
    CHAR Confidence;
} SPPHRASERULE;

// SPPHRASE_50  (x64 160 / x86 120 バイト)
typedef struct SPPHRASE_50 {
    DWORD cbSize;
    WORD LangID;
    WORD wHomophoneGroupId;
    ULONGLONG ullGrammarID;
    ULONGLONG ftStartTime;
    ULONGLONG ullAudioStreamPosition;
    DWORD ulAudioSizeBytes;
    DWORD ulRetainedSizeBytes;
    DWORD ulAudioSizeTime;
    SPPHRASERULE Rule;
    SPPHRASEPROPERTY* pProperties;
    SPPHRASEELEMENT* pElements;
    DWORD cReplacements;
    SPPHRASEREPLACEMENT* pReplacements;
    GUID SREngineID;
    DWORD ulSREnginePrivateDataSize;
    BYTE* pSREnginePrivateData;
} SPPHRASE_50;

// SPPHRASE  (x64 176 / x86 128 バイト)
typedef struct SPPHRASE {
    SPPHRASE_50 Base;
    LPWSTR pSML;
    SPSEMANTICERRORINFO* pSemanticErrorInfo;
} SPPHRASE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SPPHRASERULE
{
    public IntPtr pszName;
    public uint ulId;
    public uint ulFirstElement;
    public uint ulCountOfElements;
    public IntPtr pNextSibling;
    public IntPtr pFirstChild;
    public float SREngineConfidence;
    public sbyte Confidence;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SPPHRASE_50
{
    public uint cbSize;
    public ushort LangID;
    public ushort wHomophoneGroupId;
    public ulong ullGrammarID;
    public ulong ftStartTime;
    public ulong ullAudioStreamPosition;
    public uint ulAudioSizeBytes;
    public uint ulRetainedSizeBytes;
    public uint ulAudioSizeTime;
    public SPPHRASERULE Rule;
    public IntPtr pProperties;
    public IntPtr pElements;
    public uint cReplacements;
    public IntPtr pReplacements;
    public Guid SREngineID;
    public uint ulSREnginePrivateDataSize;
    public IntPtr pSREnginePrivateData;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SPPHRASE
{
    public SPPHRASE_50 Base;
    public IntPtr pSML;
    public IntPtr pSemanticErrorInfo;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SPPHRASERULE
    Public pszName As IntPtr
    Public ulId As UInteger
    Public ulFirstElement As UInteger
    Public ulCountOfElements As UInteger
    Public pNextSibling As IntPtr
    Public pFirstChild As IntPtr
    Public SREngineConfidence As Single
    Public Confidence As SByte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SPPHRASE_50
    Public cbSize As UInteger
    Public LangID As UShort
    Public wHomophoneGroupId As UShort
    Public ullGrammarID As ULong
    Public ftStartTime As ULong
    Public ullAudioStreamPosition As ULong
    Public ulAudioSizeBytes As UInteger
    Public ulRetainedSizeBytes As UInteger
    Public ulAudioSizeTime As UInteger
    Public Rule As SPPHRASERULE
    Public pProperties As IntPtr
    Public pElements As IntPtr
    Public cReplacements As UInteger
    Public pReplacements As IntPtr
    Public SREngineID As Guid
    Public ulSREnginePrivateDataSize As UInteger
    Public pSREnginePrivateData As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SPPHRASE
    Public Base As SPPHRASE_50
    Public pSML As IntPtr
    Public pSemanticErrorInfo As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class SPPHRASERULE(ctypes.Structure):
    _fields_ = [
        ("pszName", ctypes.c_void_p),
        ("ulId", wintypes.DWORD),
        ("ulFirstElement", wintypes.DWORD),
        ("ulCountOfElements", wintypes.DWORD),
        ("pNextSibling", ctypes.c_void_p),
        ("pFirstChild", ctypes.c_void_p),
        ("SREngineConfidence", ctypes.c_float),
        ("Confidence", ctypes.c_byte),
    ]

class SPPHRASE_50(ctypes.Structure):
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("LangID", ctypes.c_ushort),
        ("wHomophoneGroupId", ctypes.c_ushort),
        ("ullGrammarID", ctypes.c_ulonglong),
        ("ftStartTime", ctypes.c_ulonglong),
        ("ullAudioStreamPosition", ctypes.c_ulonglong),
        ("ulAudioSizeBytes", wintypes.DWORD),
        ("ulRetainedSizeBytes", wintypes.DWORD),
        ("ulAudioSizeTime", wintypes.DWORD),
        ("Rule", SPPHRASERULE),
        ("pProperties", ctypes.c_void_p),
        ("pElements", ctypes.c_void_p),
        ("cReplacements", wintypes.DWORD),
        ("pReplacements", ctypes.c_void_p),
        ("SREngineID", GUID),
        ("ulSREnginePrivateDataSize", wintypes.DWORD),
        ("pSREnginePrivateData", ctypes.c_void_p),
    ]

class SPPHRASE(ctypes.Structure):
    _fields_ = [
        ("Base", SPPHRASE_50),
        ("pSML", ctypes.c_void_p),
        ("pSemanticErrorInfo", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct SPPHRASERULE {
    pub pszName: *mut core::ffi::c_void,
    pub ulId: u32,
    pub ulFirstElement: u32,
    pub ulCountOfElements: u32,
    pub pNextSibling: *mut core::ffi::c_void,
    pub pFirstChild: *mut core::ffi::c_void,
    pub SREngineConfidence: f32,
    pub Confidence: i8,
}

#[repr(C)]
pub struct SPPHRASE_50 {
    pub cbSize: u32,
    pub LangID: u16,
    pub wHomophoneGroupId: u16,
    pub ullGrammarID: u64,
    pub ftStartTime: u64,
    pub ullAudioStreamPosition: u64,
    pub ulAudioSizeBytes: u32,
    pub ulRetainedSizeBytes: u32,
    pub ulAudioSizeTime: u32,
    pub Rule: SPPHRASERULE,
    pub pProperties: *mut core::ffi::c_void,
    pub pElements: *mut core::ffi::c_void,
    pub cReplacements: u32,
    pub pReplacements: *mut core::ffi::c_void,
    pub SREngineID: GUID,
    pub ulSREnginePrivateDataSize: u32,
    pub pSREnginePrivateData: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct SPPHRASE {
    pub Base: SPPHRASE_50,
    pub pSML: *mut core::ffi::c_void,
    pub pSemanticErrorInfo: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type SPPHRASERULE struct {
	pszName uintptr
	ulId uint32
	ulFirstElement uint32
	ulCountOfElements uint32
	pNextSibling uintptr
	pFirstChild uintptr
	SREngineConfidence float32
	Confidence int8
}

type SPPHRASE_50 struct {
	cbSize uint32
	LangID uint16
	wHomophoneGroupId uint16
	ullGrammarID uint64
	ftStartTime uint64
	ullAudioStreamPosition uint64
	ulAudioSizeBytes uint32
	ulRetainedSizeBytes uint32
	ulAudioSizeTime uint32
	Rule SPPHRASERULE
	pProperties uintptr
	pElements uintptr
	cReplacements uint32
	pReplacements uintptr
	SREngineID windows.GUID
	ulSREnginePrivateDataSize uint32
	pSREnginePrivateData uintptr
}

type SPPHRASE struct {
	Base SPPHRASE_50
	pSML uintptr
	pSemanticErrorInfo uintptr
}
type
  SPPHRASERULE = record
    pszName: Pointer;
    ulId: DWORD;
    ulFirstElement: DWORD;
    ulCountOfElements: DWORD;
    pNextSibling: Pointer;
    pFirstChild: Pointer;
    SREngineConfidence: Single;
    Confidence: Shortint;
  end;

  SPPHRASE_50 = record
    cbSize: DWORD;
    LangID: Word;
    wHomophoneGroupId: Word;
    ullGrammarID: UInt64;
    ftStartTime: UInt64;
    ullAudioStreamPosition: UInt64;
    ulAudioSizeBytes: DWORD;
    ulRetainedSizeBytes: DWORD;
    ulAudioSizeTime: DWORD;
    Rule: SPPHRASERULE;
    pProperties: Pointer;
    pElements: Pointer;
    cReplacements: DWORD;
    pReplacements: Pointer;
    SREngineID: TGUID;
    ulSREnginePrivateDataSize: DWORD;
    pSREnginePrivateData: Pointer;
  end;

  SPPHRASE = record
    Base: SPPHRASE_50;
    pSML: Pointer;
    pSemanticErrorInfo: Pointer;
  end;
const SPPHRASERULE = extern struct {
    pszName: ?*anyopaque,
    ulId: u32,
    ulFirstElement: u32,
    ulCountOfElements: u32,
    pNextSibling: ?*anyopaque,
    pFirstChild: ?*anyopaque,
    SREngineConfidence: f32,
    Confidence: i8,
};

const SPPHRASE_50 = extern struct {
    cbSize: u32,
    LangID: u16,
    wHomophoneGroupId: u16,
    ullGrammarID: u64,
    ftStartTime: u64,
    ullAudioStreamPosition: u64,
    ulAudioSizeBytes: u32,
    ulRetainedSizeBytes: u32,
    ulAudioSizeTime: u32,
    Rule: SPPHRASERULE,
    pProperties: ?*anyopaque,
    pElements: ?*anyopaque,
    cReplacements: u32,
    pReplacements: ?*anyopaque,
    SREngineID: GUID,
    ulSREnginePrivateDataSize: u32,
    pSREnginePrivateData: ?*anyopaque,
};

const SPPHRASE = extern struct {
    Base: SPPHRASE_50,
    pSML: ?*anyopaque,
    pSemanticErrorInfo: ?*anyopaque,
};
type
  SPPHRASERULE {.bycopy.} = object
    pszName: pointer
    ulId: uint32
    ulFirstElement: uint32
    ulCountOfElements: uint32
    pNextSibling: pointer
    pFirstChild: pointer
    SREngineConfidence: float32
    Confidence: int8

  SPPHRASE_50 {.bycopy.} = object
    cbSize: uint32
    LangID: uint16
    wHomophoneGroupId: uint16
    ullGrammarID: uint64
    ftStartTime: uint64
    ullAudioStreamPosition: uint64
    ulAudioSizeBytes: uint32
    ulRetainedSizeBytes: uint32
    ulAudioSizeTime: uint32
    Rule: SPPHRASERULE
    pProperties: pointer
    pElements: pointer
    cReplacements: uint32
    pReplacements: pointer
    SREngineID: GUID
    ulSREnginePrivateDataSize: uint32
    pSREnginePrivateData: pointer

  SPPHRASE {.bycopy.} = object
    Base: SPPHRASE_50
    pSML: pointer
    pSemanticErrorInfo: pointer
struct SPPHRASERULE
{
    void* pszName;
    uint ulId;
    uint ulFirstElement;
    uint ulCountOfElements;
    void* pNextSibling;
    void* pFirstChild;
    float SREngineConfidence;
    byte Confidence;
}

struct SPPHRASE_50
{
    uint cbSize;
    ushort LangID;
    ushort wHomophoneGroupId;
    ulong ullGrammarID;
    ulong ftStartTime;
    ulong ullAudioStreamPosition;
    uint ulAudioSizeBytes;
    uint ulRetainedSizeBytes;
    uint ulAudioSizeTime;
    SPPHRASERULE Rule;
    void* pProperties;
    void* pElements;
    uint cReplacements;
    void* pReplacements;
    GUID SREngineID;
    uint ulSREnginePrivateDataSize;
    void* pSREnginePrivateData;
}

struct SPPHRASE
{
    SPPHRASE_50 Base;
    void* pSML;
    void* pSemanticErrorInfo;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SPPHRASE サイズ: 128 バイト(x86)
dim st, 32    ; 4byte整数×32(構造体サイズ 128 / 4 切り上げ)
; Base : SPPHRASE_50 (+0, 120byte)  varptr(st)+0 を基点に操作(120byte:入れ子/配列)
; pSML : LPWSTR (+120, 4byte)  st.30 = 値  /  値 = st.30   (lpoke/lpeek も可)
; pSemanticErrorInfo : SPSEMANTICERRORINFO* (+124, 4byte)  varptr(st)+124 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SPPHRASE サイズ: 176 バイト(x64)
dim st, 44    ; 4byte整数×44(構造体サイズ 176 / 4 切り上げ)
; Base : SPPHRASE_50 (+0, 160byte)  varptr(st)+0 を基点に操作(160byte:入れ子/配列)
; pSML : LPWSTR (+160, 8byte)  qpoke st,160,値 / qpeek(st,160)  ※IronHSPのみ。3.7/3.8は lpoke st,160,下位 : lpoke st,164,上位
; pSemanticErrorInfo : SPSEMANTICERRORINFO* (+168, 8byte)  varptr(st)+168 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global SPPHRASERULE
    #field intptr pszName
    #field int ulId
    #field int ulFirstElement
    #field int ulCountOfElements
    #field intptr pNextSibling
    #field intptr pFirstChild
    #field float SREngineConfidence
    #field byte Confidence
#endstruct

#defstruct global GUID, pack=1
    #field int Data1
    #field short Data2
    #field short Data3
    #field byte Data4 8
#endstruct

#defstruct global SPPHRASE_50
    #field int cbSize
    #field short LangID
    #field short wHomophoneGroupId
    #field int64 ullGrammarID
    #field int64 ftStartTime
    #field int64 ullAudioStreamPosition
    #field int ulAudioSizeBytes
    #field int ulRetainedSizeBytes
    #field int ulAudioSizeTime
    #field SPPHRASERULE Rule
    #field intptr pProperties
    #field intptr pElements
    #field int cReplacements
    #field intptr pReplacements
    #field GUID SREngineID
    #field int ulSREnginePrivateDataSize
    #field intptr pSREnginePrivateData
#endstruct

#defstruct global SPPHRASE
    #field SPPHRASE_50 Base
    #field intptr pSML
    #field intptr pSemanticErrorInfo
#endstruct

stdim st, SPPHRASE        ; NSTRUCT 変数を確保