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

SPVSTATE

構造体
サイズx64: 72 バイト / x86: 52 バイト

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

フィールド

フィールドサイズx64x86説明
eActionSPVACTIONS4+0+0現在の音声合成アクション(SPVACTIONS)。
LangIDWORD2+4+4発話の言語ID(LANGID)。
wReservedWORD2+6+6予約領域。使用しない。
EmphAdjINT4+8+8強調(エンファシス)の調整量。
RateAdjINT4+12+12話速の調整量。正で速く負で遅くなる。
VolumeDWORD4+16+16音量。0~100の範囲で指定する。
PitchAdjSPVPITCH8+20+20ピッチ調整情報(SPVPITCH)。
SilenceMSecsDWORD4+28+28挿入する無音時間をミリ秒で指定する。
pPhoneIdsWORD*8/4+32+32明示指定する音素ID配列へのポインタ。NULL可。
ePartOfSpeechSPPARTOFSPEECH4+40+36品詞(SPPARTOFSPEECH)。
ContextSPVCONTEXT24/12+48+40正規化の文脈情報(SPVCONTEXT)。

各言語での定義

#include <windows.h>

// SPVPITCH  (x64 8 / x86 8 バイト)
typedef struct SPVPITCH {
    INT MiddleAdj;
    INT RangeAdj;
} SPVPITCH;

// SPVCONTEXT  (x64 24 / x86 12 バイト)
typedef struct SPVCONTEXT {
    LPWSTR pCategory;
    LPWSTR pBefore;
    LPWSTR pAfter;
} SPVCONTEXT;

// SPVSTATE  (x64 72 / x86 52 バイト)
typedef struct SPVSTATE {
    SPVACTIONS eAction;
    WORD LangID;
    WORD wReserved;
    INT EmphAdj;
    INT RateAdj;
    DWORD Volume;
    SPVPITCH PitchAdj;
    DWORD SilenceMSecs;
    WORD* pPhoneIds;
    SPPARTOFSPEECH ePartOfSpeech;
    SPVCONTEXT Context;
} SPVSTATE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SPVPITCH
{
    public int MiddleAdj;
    public int RangeAdj;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SPVCONTEXT
{
    public IntPtr pCategory;
    public IntPtr pBefore;
    public IntPtr pAfter;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SPVSTATE
{
    public int eAction;
    public ushort LangID;
    public ushort wReserved;
    public int EmphAdj;
    public int RateAdj;
    public uint Volume;
    public SPVPITCH PitchAdj;
    public uint SilenceMSecs;
    public IntPtr pPhoneIds;
    public int ePartOfSpeech;
    public SPVCONTEXT Context;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SPVPITCH
    Public MiddleAdj As Integer
    Public RangeAdj As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SPVCONTEXT
    Public pCategory As IntPtr
    Public pBefore As IntPtr
    Public pAfter As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SPVSTATE
    Public eAction As Integer
    Public LangID As UShort
    Public wReserved As UShort
    Public EmphAdj As Integer
    Public RateAdj As Integer
    Public Volume As UInteger
    Public PitchAdj As SPVPITCH
    Public SilenceMSecs As UInteger
    Public pPhoneIds As IntPtr
    Public ePartOfSpeech As Integer
    Public Context As SPVCONTEXT
End Structure
import ctypes
from ctypes import wintypes

class SPVPITCH(ctypes.Structure):
    _fields_ = [
        ("MiddleAdj", ctypes.c_int),
        ("RangeAdj", ctypes.c_int),
    ]

class SPVCONTEXT(ctypes.Structure):
    _fields_ = [
        ("pCategory", ctypes.c_void_p),
        ("pBefore", ctypes.c_void_p),
        ("pAfter", ctypes.c_void_p),
    ]

class SPVSTATE(ctypes.Structure):
    _fields_ = [
        ("eAction", ctypes.c_int),
        ("LangID", ctypes.c_ushort),
        ("wReserved", ctypes.c_ushort),
        ("EmphAdj", ctypes.c_int),
        ("RateAdj", ctypes.c_int),
        ("Volume", wintypes.DWORD),
        ("PitchAdj", SPVPITCH),
        ("SilenceMSecs", wintypes.DWORD),
        ("pPhoneIds", ctypes.c_void_p),
        ("ePartOfSpeech", ctypes.c_int),
        ("Context", SPVCONTEXT),
    ]
#[repr(C)]
pub struct SPVPITCH {
    pub MiddleAdj: i32,
    pub RangeAdj: i32,
}

#[repr(C)]
pub struct SPVCONTEXT {
    pub pCategory: *mut core::ffi::c_void,
    pub pBefore: *mut core::ffi::c_void,
    pub pAfter: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct SPVSTATE {
    pub eAction: i32,
    pub LangID: u16,
    pub wReserved: u16,
    pub EmphAdj: i32,
    pub RateAdj: i32,
    pub Volume: u32,
    pub PitchAdj: SPVPITCH,
    pub SilenceMSecs: u32,
    pub pPhoneIds: *mut core::ffi::c_void,
    pub ePartOfSpeech: i32,
    pub Context: SPVCONTEXT,
}
import "golang.org/x/sys/windows"

type SPVPITCH struct {
	MiddleAdj int32
	RangeAdj int32
}

type SPVCONTEXT struct {
	pCategory uintptr
	pBefore uintptr
	pAfter uintptr
}

type SPVSTATE struct {
	eAction int32
	LangID uint16
	wReserved uint16
	EmphAdj int32
	RateAdj int32
	Volume uint32
	PitchAdj SPVPITCH
	SilenceMSecs uint32
	pPhoneIds uintptr
	ePartOfSpeech int32
	Context SPVCONTEXT
}
type
  SPVPITCH = record
    MiddleAdj: Integer;
    RangeAdj: Integer;
  end;

  SPVCONTEXT = record
    pCategory: Pointer;
    pBefore: Pointer;
    pAfter: Pointer;
  end;

  SPVSTATE = record
    eAction: Integer;
    LangID: Word;
    wReserved: Word;
    EmphAdj: Integer;
    RateAdj: Integer;
    Volume: DWORD;
    PitchAdj: SPVPITCH;
    SilenceMSecs: DWORD;
    pPhoneIds: Pointer;
    ePartOfSpeech: Integer;
    Context: SPVCONTEXT;
  end;
const SPVPITCH = extern struct {
    MiddleAdj: i32,
    RangeAdj: i32,
};

const SPVCONTEXT = extern struct {
    pCategory: ?*anyopaque,
    pBefore: ?*anyopaque,
    pAfter: ?*anyopaque,
};

const SPVSTATE = extern struct {
    eAction: i32,
    LangID: u16,
    wReserved: u16,
    EmphAdj: i32,
    RateAdj: i32,
    Volume: u32,
    PitchAdj: SPVPITCH,
    SilenceMSecs: u32,
    pPhoneIds: ?*anyopaque,
    ePartOfSpeech: i32,
    Context: SPVCONTEXT,
};
type
  SPVPITCH {.bycopy.} = object
    MiddleAdj: int32
    RangeAdj: int32

  SPVCONTEXT {.bycopy.} = object
    pCategory: pointer
    pBefore: pointer
    pAfter: pointer

  SPVSTATE {.bycopy.} = object
    eAction: int32
    LangID: uint16
    wReserved: uint16
    EmphAdj: int32
    RateAdj: int32
    Volume: uint32
    PitchAdj: SPVPITCH
    SilenceMSecs: uint32
    pPhoneIds: pointer
    ePartOfSpeech: int32
    Context: SPVCONTEXT
struct SPVPITCH
{
    int MiddleAdj;
    int RangeAdj;
}

struct SPVCONTEXT
{
    void* pCategory;
    void* pBefore;
    void* pAfter;
}

struct SPVSTATE
{
    int eAction;
    ushort LangID;
    ushort wReserved;
    int EmphAdj;
    int RateAdj;
    uint Volume;
    SPVPITCH PitchAdj;
    uint SilenceMSecs;
    void* pPhoneIds;
    int ePartOfSpeech;
    SPVCONTEXT Context;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SPVSTATE サイズ: 52 バイト(x86)
dim st, 13    ; 4byte整数×13(構造体サイズ 52 / 4 切り上げ)
; eAction : SPVACTIONS (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; LangID : WORD (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; wReserved : WORD (+6, 2byte)  wpoke st,6,値  /  値 = wpeek(st,6)
; EmphAdj : INT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; RateAdj : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; Volume : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; PitchAdj : SPVPITCH (+20, 8byte)  varptr(st)+20 を基点に操作(8byte:入れ子/配列)
; SilenceMSecs : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; pPhoneIds : WORD* (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ePartOfSpeech : SPPARTOFSPEECH (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; Context : SPVCONTEXT (+40, 12byte)  varptr(st)+40 を基点に操作(12byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SPVSTATE サイズ: 72 バイト(x64)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; eAction : SPVACTIONS (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; LangID : WORD (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; wReserved : WORD (+6, 2byte)  wpoke st,6,値  /  値 = wpeek(st,6)
; EmphAdj : INT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; RateAdj : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; Volume : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; PitchAdj : SPVPITCH (+20, 8byte)  varptr(st)+20 を基点に操作(8byte:入れ子/配列)
; SilenceMSecs : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; pPhoneIds : WORD* (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ePartOfSpeech : SPPARTOFSPEECH (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; Context : SPVCONTEXT (+48, 24byte)  varptr(st)+48 を基点に操作(24byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global SPVPITCH
    #field int MiddleAdj
    #field int RangeAdj
#endstruct

#defstruct global SPVCONTEXT
    #field intptr pCategory
    #field intptr pBefore
    #field intptr pAfter
#endstruct

#defstruct global SPVSTATE
    #field int eAction
    #field short LangID
    #field short wReserved
    #field int EmphAdj
    #field int RateAdj
    #field int Volume
    #field SPVPITCH PitchAdj
    #field int SilenceMSecs
    #field intptr pPhoneIds
    #field int ePartOfSpeech
    #field SPVCONTEXT Context
#endstruct

stdim st, SPVSTATE        ; NSTRUCT 変数を確保
st->eAction = 100
mes "eAction=" + st->eAction