v2

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2021 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SymInvalid = iota

	SymAdd

	SymSub

	SymMult

	SymDiv

	SymRtParen

	SymLftParen

	SymString

	SymTypeN
)
View Source
const (
	FormulaSymTransition1 = iota
	FormulaSymTransition2
	FormulaSymTransition3
	FormulaSymTransition4
	FormulaSymQssa1
	FormulaSymQssa2
	FormulaSymQssa3
	FormulaSymQssa4
	FormulaSymQssb1
	FormulaSymQssb2
	FormulaSymQssb3
	FormulaSymQssb4
	FormulaSymTempo1
	FormulaSymTempo2
	FormulaSymTempo3
	FormulaSymTempo4
	FormulaSymRd
	FormulaSymBeat
	FormulaSymMark1
	FormulaSymMark2
	FormulaSymMark3
	FormulaSymTypeN
)
View Source
const (
	OroPharynxReg1 = iota // S1
	OroPharynxReg2        // S2
	OroPharynxReg3        // S3
	OroPharynxReg4        // S4 & S5
	OroPharynxReg5        // S6 & S7
	OroPharynxReg6        // S8
	OroPharynxReg7        // S9
	OroPharynxReg8        // S10
	OroPharynxRegCnt
)
View Source
const (
	OroPharynxC1 = iota // R1-R2 (S1-S2)
	OroPharynxC2        // R2-R3 (S2-S3)
	OroPharynxC3        // R3-R4 (S3-S4)
	OroPharynxC4        // R4-R5 (S5-S6)
	OroPharynxC5        // R5-R6 (S7-S8)
	OroPharynxC6        // R6-R7 (S8-S9)
	OroPharynxC7        // R7-R8 (S9-S10)
	OroPharynxC8        // R8-Air (S10-Air)
	OroPharynxCoefCnt
)
View Source
const (
	OroPharynxS1  = iota // OroPharynxReg1
	OroPharynxS2         // OroPharynxReg2
	OroPharynxS3         // OroPharynxReg3
	OroPharynxS4         // OroPharynxReg4
	OroPharynxS5         // OroPharynxReg4
	OroPharynxS6         // OroPharynxReg5
	OroPharynxS7         // OroPharynxReg5
	OroPharynxS8         // OroPharynxReg6
	OroPharynxS9         // OroPharynxReg7
	OroPharynxS10        // OroPharynxReg8
	OroPharynxSectCnt
)
View Source
const (
	NasalS1 = iota
	NasalS2
	NasalS3
	NasalS4
	NasalS5
	NasalS6
	NasalSectCnt
	Velum = NasalS1
)
View Source
const (
	NasalC1      = NasalS1 // N1-N2
	NasalC2      = NasalS2 // N2-N3
	NasalC3      = NasalS3 // N3-N4
	NasalC4      = NasalS4 // N4-N5
	NasalC5      = NasalS5 // N5-N6
	NasalC6      = NasalS6 // N6-Air
	NasalCoefCnt = NasalSectCnt
)
View Source
const (
	ThreeWayLeft = iota
	ThreeWayRight
	ThreeWayUpper
	ThreeWayCnt
)
View Source
const (
	FricationInjC1 = iota // S3
	FricationInjC2        // S4
	FricationInjC3        // S5
	FricationInjC4        // S6
	FricationInjC5        // S7
	FricationInjC6        // S8
	FricationInjC7        // S9
	FricationInjC8        // S10
	FricationInjCoefCnt
)
View Source
const Bottom = 1
View Source
const DiPhone = 2
View Source
const Factor = 377.0
View Source
const GlottalSourcePulse = 0
View Source
const GlottalSourceSine = 1
View Source
const GsTrmTubeMinRadius = 0.001
View Source
const InitialSeed = 0.7892347
View Source
const OutputScale = 0.95
View Source
const PitchBase = 220.0
View Source
const PitchOffset = 3
View Source
const TetraPhone = 4
View Source
const Top = 0
View Source
const TriPhone = 3
View Source
const VolMax = 60
View Source
const VtScale = 0.125

Variables

View Source
var Kit_FormulaSymbolType = kit.Enums.AddEnum(FormulaSymTypeN, kit.NotBitFlag, nil)
View Source
var Kit_Intonation = kit.Enums.AddEnum(IntonationFlagsN, kit.BitFlag, nil)
View Source
var Kit_LogicNodeType = kit.Enums.AddEnum(LogicNodeTypeN, kit.NotBitFlag, nil)
View Source
var Kit_LogicSymbolType = kit.Enums.AddEnum(LogicSymTypeN, kit.NotBitFlag, nil)
View Source
var Kit_NodeType = kit.Enums.AddEnum(NodeTypeN, kit.NotBitFlag, nil)
View Source
var Kit_SymbolType = kit.Enums.AddEnum(SymTypeN, kit.NotBitFlag, nil)
View Source
var Kit_ToneType = kit.Enums.AddEnum(ToneTypeN, kit.NotBitFlag, nil)
View Source
var Kit_TransitionType = kit.Enums.AddEnum(TransTypeN, kit.NotBitFlag, nil)

Functions

func Amplitude

func Amplitude(decibelLevel float64) float64

Amplitude converts dB value to amplitude value

func Frequency

func Frequency(pitch float64) float64

Frequency converts a given pitch (0 = middle C) to the corresponding frequency

func IsSeparator

func IsSeparator(c string) bool

func NewFormulaSymMap

func NewFormulaSymMap() *map[string]FormulaSymbolType

func PlaySound

func PlaySound()

func PointData

func PointData(pt Point, model *Model) (time, value float64)

PointData

func PointDataMinMax

func PointDataMinMax(pt Point, model *Model, baseline, delta, min, max float64) (time, value float64)

PointDataMinMax

func PointTime

func PointTime(pt Point, model *Model) float64

PointTime

func SpeedOfSound

func SpeedOfSound(temp float64) float64

SpeedOfSound returns the speed of sound according to the value of the temperature (in Celsius degrees)

Types

type BoolNode

type BoolNode struct {
	Type     LogicNodeType
	Child1   *BoolNode
	Child2   *BoolNode
	Cat      *Category
	MatchAll bool
}

func (*BoolNode) BoolNodeEval

func (bn *BoolNode) BoolNodeEval(pos *Posture) bool

type Category

type Category struct {
	Name    string `xml:"name,attr"`
	Comment string `xml:"comment"`
	Native  bool
}

type Control

type Control struct {
	Model       *Model
	Sequence    *Sequence
	ModelConfig ModelConfig
	TrmConfig   TrmConfig
	Tube        *Tube `view:"noinline"`
}

func NewControl

func NewControl(path string, model *Model) *Control

func (*Control) CalcChunks

func (ctrl *Control) CalcChunks(text string) int

Chunks are separated by /c. There is always one /c at the begin and another at the end of the string.

func (*Control) InitUtterance

func (ctrl *Control) InitUtterance(w *bufio.Writer)

func (*Control) NextChunk

func (ctrl *Control) NextChunk(text string) int

NextChunk returns the position of the next /c (the position of the /).

func (*Control) PhoneticParse

func (ctrl *Control) PhoneticParse(psp PhoneticParser, pString string, writer *bufio.Writer)

func (*Control) SetIntonation

func (ctrl *Control) SetIntonation(intonation int64)

SetIntonation

func (*Control) SynthPhoneticStringChunk

func (ctrl *Control) SynthPhoneticStringChunk(psp PhoneticParser, pschunk string, writer *bufio.Writer)

func (*Control) SynthPhoneticStringToBuf

func (ctrl *Control) SynthPhoneticStringToBuf(psp PhoneticParser, pString, trmParamFile string, buf []float64)

func (*Control) SynthPhoneticStringToFile

func (ctrl *Control) SynthPhoneticStringToFile(psp PhoneticParser, pString, trmParamFile, outputFile string)

func (*Control) SynthSequenceToBuf

func (ctrl *Control) SynthSequenceToBuf(trmParaFile string, buf []float64)

SynthSequenceToBuf synthesizes speech from data contained in the event list

func (*Control) SynthSequenceToFile

func (ctrl *Control) SynthSequenceToFile(trmParamFile, outputFile string)

SynthSequenceToFile synthesizes speech from data contained in the event list

func (*Control) ValidPosture

func (ctrl *Control) ValidPosture(token string) bool

ValidPosture

type Drift

type Drift struct {
	Deviation float64 `desc:"the amount of drift in semitones above and below the median.  A value around 1 or so should give good results."`
	Offset    float64 `desc:"pitch offset"`
	Seed      float64 `desc:""`
	A0        float64 `desc:""`
	B1        float64 `desc:""`
	PrvSample float64 `desc:""`
}

func NewDrift

func NewDrift() *Drift

func (*Drift) Drift

func (dg *Drift) Drift() float64

Drift returns one sample of the drift signal

func (*Drift) SetUp

func (dg *Drift) SetUp(deviation, sr, lpcutoff float64)

Setup sets the params - deviation value around 1 should be good, sr the sample rate of the system in Hz---this should be the same as the control rate (250 Hz), lpcutoff - the cutoff in Hz of the lowpass filter applied to the noise generator. This value must range from 0 Hz to nyquist. A low value around 1 - 4 Hz should give good results.

type EqGrp

type EqGrp struct {
	XMLName   xml.Name    `xml:"equation-group"`
	Name      string      `xml:"name,attr"`
	Equations []*Equation `xml:"equation"`
}

type Equation

type Equation struct {
	Name        string `xml:"name,attr"`
	Comment     string `xml:"comment"`
	Formula     string `xml:"formula,attr"`
	FormulaRoot *FormulaNode
}

func (*Equation) EvalFormula

func (eq *Equation) EvalFormula(sl *FormulaValueList) float64

func (*Equation) SetFormula

func (eq *Equation) SetFormula(formula string) *FormulaNode

type Event

type Event struct {
	Params []float64
	Size   int
	Time   int
	Flag   int
}

func NewEvent

func NewEvent() *Event

func (*Event) SetValue

func (ev *Event) SetValue(v float64, idx int)

func (*Event) Value

func (ev *Event) Value(idx int) float64

type ExprSymEquation

type ExprSymEquation struct {
	SymName  string `xml:"attr,name"`
	EqName   string `xml:"attr,equation"`
	Equation *Equation
}
type Foot struct {
	Onset1 float64
	Onset2 float64
	Tempo  float64
	Start  int
	End    int
	Marked bool
	Last   bool
}

func (*Foot) Defaults

func (ft *Foot) Defaults()

type FormulaNode

type FormulaNode struct {
	Type     NodeType
	Child1   *FormulaNode
	Child2   *FormulaNode
	Symbol   FormulaSymbolType `desc:"These are dynamic variables looked up from a map"`
	ConstVal float64           `desc:"Constants in some formulas"`
}

func NewFormulaConstNode

func NewFormulaConstNode(val float64) *FormulaNode

NewFormulaSymbolNode is a special case for variables of type FormulaSymbolType

func NewFormulaNode

func NewFormulaNode(c1 *FormulaNode, c2 *FormulaNode, nodeType NodeType) *FormulaNode

NewFormulaNode

func NewFormulaSymbolNode

func NewFormulaSymbolNode(symbol FormulaSymbolType) *FormulaNode

NewFormulaSymbolNode is a special case for variables of type FormulaSymbolType

func (*FormulaNode) Eval

func (fn *FormulaNode) Eval(sl *FormulaValueList) float64

type FormulaNodeParser

type FormulaNodeParser struct {
	FormulaValueList FormulaValueList
	S                string
	Pos              int
	Symbol           string
	SymbolType       SymbolType
}

func NewFormulaNodeParser

func NewFormulaNodeParser(s string) *FormulaNodeParser

func (*FormulaNodeParser) Finished

func (fnp *FormulaNodeParser) Finished() bool

func (*FormulaNodeParser) NextSymbol

func (fnp *FormulaNodeParser) NextSymbol()

func (*FormulaNodeParser) Parse

func (fnp *FormulaNodeParser) Parse() *FormulaNode

Parse

func (*FormulaNodeParser) ParseExpr

func (fnp *FormulaNodeParser) ParseExpr() *FormulaNode

ParseExpr EXPRESSION -> TERM { ADD_OP TERM }

func (*FormulaNodeParser) ParseFactor

func (fnp *FormulaNodeParser) ParseFactor() *FormulaNode

Parse Factor -- FACTOR -> "(" EXPRESSION ")" | SYMBOL | CONST | ADD_OP FACTOR

func (*FormulaNodeParser) ParseTerm

func (fnp *FormulaNodeParser) ParseTerm() *FormulaNode

ParseTerm TERM -> FACTOR { MULT_OP FACTOR }

func (*FormulaNodeParser) SkipSpaces

func (fnp *FormulaNodeParser) SkipSpaces()

SkipSpaces moves the index into string past white space

type FormulaSymMap

type FormulaSymMap struct {
	SymMap map[string]FormulaSymbolType
}

type FormulaSymbolType

type FormulaSymbolType int

FormulaSymbolType

type FormulaValueList

type FormulaValueList [FormulaSymTypeN]float64

type FricationInjCoefs

type FricationInjCoefs int32

FricationInjCoefs are the oropharynx scattering junction coefficients (between each region)

type IntRange

type IntRange struct {
	Min int
	Max int
}

IntRange is the way to specify the min and max values for an integer range (used here when generating random numbers)

type IntonationFlags

type IntonationFlags int64

IntonationFlags

const (
	// 0x01
	IntonationMicro IntonationFlags = iota

	// 0x02
	IntonationMacro

	// 0x04
	IntonationSmooth

	// 0x08
	IntonationDrift

	// 0x10
	IntonationRandom

	IntonationFlagsN
)

type IntonationPt

type IntonationPt struct {
	SemiTone float64   `desc:"value of the intonation in semitones"`
	Offset   float64   `desc:"points are timed wrt a beat + this offset"`
	Slope    float64   `desc:"Slope of point"`
	RuleIdx  int       `desc:"Index of posture which is the focus of this point"`
	Sequence *Sequence `desc:"Current events"`
}

func NewIntonationPt

func NewIntonationPt(seq *Sequence) *IntonationPt

func (*IntonationPt) AbsTime

func (ip *IntonationPt) AbsTime() float64

func (*IntonationPt) BeatTime

func (ip *IntonationPt) BeatTime() float64

type LogicNodeType

type LogicNodeType int
const (
	// LogicSymInvalid
	LogicNodeInvalid LogicNodeType = iota

	//
	LogicNodeOr

	//
	LogicNodeNot

	//
	LogicNodeXor

	//
	LogicNodeAnd

	//
	LogicNodeTerminal

	LogicNodeTypeN
)

type LogicSymbolType

type LogicSymbolType int
const (
	// LogicSymInvalid
	LogicSymInvalid LogicSymbolType = iota

	//
	LogicSymOr

	//
	LogicSymNot

	//
	LogicSymXor

	//
	LogicSymAnd

	//
	LogicSymRtParen

	//
	LogicSymLftParen

	//
	LogicSymString

	LogicSymTypeN
)

type Model

type Model struct {
	Categories  []Category  `xml:"categories>category"`
	Params      []Param     `xml:"parameters>parameter"`
	Symbols     []Symbol    `xml:"symbols>symbol"`
	Postures    []Posture   `xml:"postures>posture"`
	Rules       []*Rule     `xml:"rules>rule"`
	EqGrps      []EqGrp     `xml:"equations>equation-group"`
	TransGrps   TransGrps   `xml:"transitions>transition-group"`
	TransGrpsSp TransGrpsSp `xml:"special-transitions>transition-group"`
	FormulaVals FormulaValueList
}

func LoadModel

func LoadModel(path string) *Model

Load the model configuration - the monet.xml file (postures, intonation, etc)

func (*Model) CategoryTry

func (mdl *Model) CategoryTry(nm string) *Category

CategoryTry returns the address of the named Category or nil if not found

func (*Model) ClearFormulaVals

func (mdl *Model) ClearFormulaVals()

func (*Model) EquationGroupTry

func (mdl *Model) EquationGroupTry(nm string) *EqGrp

EquationGroupTry

func (*Model) EquationIndexTry

func (mdl *Model) EquationIndexTry(nm string) (grpIdx, eqIdx int)

EquationIndexTry returns the group and equation index if name is found, otherwise -1, -1

func (*Model) EquationTry

func (mdl *Model) EquationTry(nm string) *Equation

EquationTry

func (*Model) EvalEquationFormula

func (mdl *Model) EvalEquationFormula(eq *Equation) float64

EvalEquationFormula

func (*Model) FirstRule

func (mdl *Model) FirstRule(postureSequence []Posture, ruleIdx int) (*Rule, int)

FirstRule finds the first Rule that matches the given sequence of Postures. Returns rule and index

func (*Model) Param

func (mdl *Model) Param(idx int) (*Param, error)

Param returns the parameter at given index

func (*Model) ParamIdx

func (mdl *Model) ParamIdx(nm string) int

ParamIdx returns the index or -1 if not found

func (*Model) ParamMax

func (mdl *Model) ParamMax(idx int) (float64, error)

ParamMax returns the minimum parameter value

func (*Model) ParamMin

func (mdl *Model) ParamMin(idx int) (float64, error)

ParamMin returns the minimum parameter value

func (*Model) ParamTry

func (mdl *Model) ParamTry(nm string) *Param

ParamTry returns the address of the named Param or nil if not found

func (*Model) PostureTry

func (mdl *Model) PostureTry(nm string) *Posture

CategoryTry returns the address of the named Posture or nil if not found

func (*Model) Reset

func (mdl *Model) Reset()

Reset

func (*Model) Save

func (mdl *Model) Save(configDir, configFile string)

Save

func (*Model) SymbolTry

func (mdl *Model) SymbolTry(nm string) *Symbol

SymbolTry returns the address of the named Symbol or nil if not found

func (*Model) TransitionGroupIndexTry

func (mdl *Model) TransitionGroupIndexTry(nm string) (grpIdx, eqIdx int)

TransitionGroupIndexTry returns the group and transition index if name is found, otherwise -1, -1

func (*Model) TransitionGroupSpIndexTry

func (mdl *Model) TransitionGroupSpIndexTry(nm string) (grpIdx, eqIdx int)

TransitionGroupSpIndexTry returns the special group and transition index if name is found, otherwise -1, -1

func (*Model) TransitionGroupSpTry

func (mdl *Model) TransitionGroupSpTry(nm string) *TransGrp

TransitionGroupSpTry returns the address of the named special TransitionGroup or nil if not found

func (*Model) TransitionGroupTry

func (mdl *Model) TransitionGroupTry(nm string) *TransGrp

TransitionGrpTry returns the address of the named TransitionGroup or nil if not found

func (*Model) TransitionSpTry

func (mdl *Model) TransitionSpTry(nm string) *Transition

TransitionSpTry returns the address of the named special Transition or nil if not found

func (*Model) TransitionTry

func (mdl *Model) TransitionTry(nm string) *Transition

TransitionTry returns the address of the named Transition or nil if not found

type ModelConfig

type ModelConfig struct {
	Name             string
	Desc             string
	Voice            string
	ControlRate      float64 `desc:"1.0-1000.0 input tables/second (Hz)"`
	Tempo            float64
	PitchOffset      float64
	DriftDeviation   float64
	DriftLowCutoff   float64
	Intonation       int64 `desc:"Holds IntonationFlags"`
	MicroIntonation  int   `desc:"One of 5 types of intonation"`
	MacroIntonation  int   `desc:"One of 5 types of intonation"`
	SmoothIntonation int   `desc:"One of 5 types of intonation"`
	DriftIntonation  int   `desc:"One of 5 types of intonation"`
	RandomIntonation int   `desc:"One of 5 types of intonation"`

	// Intonation parameters.
	NotionalPitch float64
	PretonicRange float64
	PretonicLift  float64
	TonicRange    float64
	TonicMovement float64

	Dictionary1 string
	Dictionary2 string
	Dictionary3 string
}

func (*ModelConfig) Defaults

func (mc *ModelConfig) Defaults()

func (*ModelConfig) Load

func (mc *ModelConfig) Load(path string) error

Load will be passed data/en/trm_control_model.config or equivalent file

func (*ModelConfig) OpenJSON

func (mc *ModelConfig) OpenJSON(fn string) error

OpenJSON opens model config from a JSON-formatted file (i.e. model params)

type NasalCoefs

type NasalCoefs int32

NasalCoefs

type NasalSections

type NasalSections int32

NasalSections are different sections of the nasal tract

type NodeType

type NodeType int
const (
	// NodeInvalid
	NodeMinusUnary NodeType = iota

	//
	NodeAdd

	//
	NodeSub

	//
	NodeMult

	//
	NodeDiv

	//
	NodeConst

	//
	NodeSym

	NodeTypeN
)

type OroPharynxCoefs

type OroPharynxCoefs int32

OroPharynxCoefs are the oropharynx scattering junction coefficients (between each region)

type OroPharynxRegions

type OroPharynxRegions int32

OroPharynxRegions are different regions of the vocal tract

type OroPharynxSects

type OroPharynxSects int32

OroPharynxCoefs are the oropharynx scattering junction coefficients (between each region)

type Param

type Param struct {
	Name    string  `xml:"name,attr"`
	Min     float64 `xml:"minimum,attr"`
	Max     float64 `xml:"maximum,attr"`
	Default float64 `xml:"default,attr"`
	Comment string  `xml:"comment,attr"`
}

func (*Param) Set

func (prm *Param) Set(nm string, min, max, dflt float64, comment string)

type ParamTransition

type ParamTransition struct {
	Name       string `xml:"attr,name"`
	Type       string `xml:"attr,transition"`
	Transition *Transition
}

type Parser

type Parser struct {
	Model   *Model
	Str     string
	Pos     int
	Symbol  string
	SymType LogicSymbolType
}

Parse

func NewParser

func NewParser(s string, model *Model) *Parser

func (*Parser) Finished

func (pars *Parser) Finished() bool

func (*Parser) GetBoolNode

func (pars *Parser) GetBoolNode() *BoolNode

GetNode returns the next boolean node

func (*Parser) NextSymbol

func (pars *Parser) NextSymbol()

NextSymbol

func (*Parser) Parse

func (pars *Parser) Parse() *BoolNode

Parse

func (*Parser) SkipSpaces

func (pars *Parser) SkipSpaces()

SkipSpaces moves the index into string past white space

type PhoneticParser

type PhoneticParser interface {
	ParseString(s string) int
}

type Point

type Point struct {
	PointOrSlope
	Type      TransitionType `xml:"type,attr"`
	Value     float64        `xml:"value,attr"`
	IsPhantom bool           `xml:"is-phantom,attr"`
	FreeTime  float64        `xml:"free-time,attr" desc:"milliseconds"`
	TimeExpr  *Equation      `xml:"time-expression,attr"`
}

Point -- If timeExpression is not empty, time = timeExpression, otherwise time = freeTime.

func NewPoint

func NewPoint() *Point

NewPoint

func (*Point) IsSlopeRatio

func (pt *Point) IsSlopeRatio() bool

type PointOrSlope

type PointOrSlope struct {
}

func (*PointOrSlope) IsSlopeRatio

func (pos *PointOrSlope) IsSlopeRatio() bool

type Posture

type Posture struct {
	Name         string     `xml:"symbol,attr"`
	Categories   []Category `xml:"posture-categories>category-ref"`
	ParamTargets []Target   `xml:"parameter-targets>target"`
	SymTargets   []Target   `xml:"symbol-targets>target"`
	Comment      string     `xml:"comment"`
}

func NewPosture

func NewPosture(nm string, paramN, symN int) *Posture

func (*Posture) CategoryTry

func (pos *Posture) CategoryTry(nm string) *Category

CategoryTry returns the address of the named Posture or nil if not found

func (*Posture) Copy

func (pos *Posture) Copy(newNm string) *Posture

func (*Posture) IsMemberOfCategory

func (pos *Posture) IsMemberOfCategory(category *Category) bool

type PostureData

type PostureData struct {
	Syllable  bool
	Onset     float64
	RuleTempo float64
	Posture   *Posture
}

func (*PostureData) Defaults

func (pd *PostureData) Defaults()

type Rule

type Rule struct {
	BoolExprs          []string           `xml:"boolean-expressions>boolean-expression"`
	ParamTransitions   []*ParamTransition `xml:"parameter-profiles>parameter-transition"`
	SpecialTransitions []*ParamTransition `xml:"special-profiles>parameter-transition"`
	ExprSymEquations   []*ExprSymEquation `xml:"expression-symbols>symbol-equation"`
	Comment            string             `xml:"comment"`
	BoolNodes          []BoolNode
}

func (*Rule) EvalBoolExpr

func (r *Rule) EvalBoolExpr(postures []Posture) bool

func (*Rule) EvalExprSyms

func (r *Rule) EvalExprSyms(tempos []float64, postures []Posture, model *Model, syms []*float64)

EvalExpr

func (*Rule) ExprEq

func (r *Rule) ExprEq(nm string) *ExprSymEquation

func (*Rule) SetExprList

func (r *Rule) SetExprList(exprs []string, model *Model) *[]BoolNode

func (*Rule) UnmarshalXML

func (r *Rule) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type RuleData

type RuleData struct {
	Number       int
	FirstPosture int
	LastPosture  int
	Duration     float64
	Beat         float64
}

func (*RuleData) Defaults

func (rl *RuleData) Defaults()

type Sequence

type Sequence struct {
	Model  *Model
	Events []Event

	ZeroRef               int
	ZeroIdx               int
	Duration              int
	TimeQuant             int
	MacroFlag             bool
	MicroFlag             bool
	DriftFlag             bool
	SmoothInton           bool
	PitchMean             float64
	GlobalTempo           float64
	Multiplier            float64
	PostureDatum          []*PostureData
	PostureTempos         []float64
	CurPosture            int
	Feet                  []*Foot
	CurFoot               int
	ToneGroups            []*ToneGroup
	CurToneGroup          ToneType
	RuleDatum             []*RuleData
	CurRule               int
	Min                   [16]float64
	Max                   [16]float64
	IntonationPts         []IntonationPt
	Drift                 *Drift
	TgUseRandom           bool
	IntonRandom           float64
	TgParams              [][]float64
	TgCount               []int
	UseFixedIntonation    bool
	IntonationParams      []float64 `desc:"these will be the random intonation values or the fixed if useFixed is true"`
	IntonationParamsFixed []float64
	RadiusCoef            []float64 // TRM::Tube::TOTAL_REGIONS

	Rand *rand.Rand
	// contains filtered or unexported fields
}

func NewSequence

func NewSequence(intonationPath string, model *Model) *Sequence

func (*Sequence) AddFoot

func (seq *Sequence) AddFoot()

func (*Sequence) AddIntonationPoint

func (seq *Sequence) AddIntonationPoint(semiTone, offsetTime, slope float64, ruleIdx int)

func (*Sequence) AddPosture

func (seq *Sequence) AddPosture()

func (*Sequence) AddToneGroup

func (seq *Sequence) AddToneGroup()

func (*Sequence) ApplyIntonation

func (seq *Sequence) ApplyIntonation()

func (*Sequence) ApplyIntonationSmooth

func (seq *Sequence) ApplyIntonationSmooth()

func (*Sequence) ApplyRule

func (seq *Sequence) ApplyRule(rule *Rule, postures []Posture, tempos []float64, postureIdx int)

It is assumed that postureList.size() >= 2. ApplyRule

func (*Sequence) ClearMacroIntonation

func (seq *Sequence) ClearMacroIntonation()

func (*Sequence) GenOutput

func (seq *Sequence) GenOutput(w *bufio.Writer)

func (*Sequence) GenerateEventList

func (seq *Sequence) GenerateEventList()

func (*Sequence) GetBeatAtIndex

func (seq *Sequence) GetBeatAtIndex(idx int) float64

func (*Sequence) InitToneGroups

func (seq *Sequence) InitToneGroups(intonationPath string) error

func (*Sequence) InsertEvent

func (seq *Sequence) InsertEvent(n int, t, v float64) *Event

InsertEvent

func (*Sequence) NewPostureWithObject

func (seq *Sequence) NewPostureWithObject(p *Posture)

func (*Sequence) ParseGroups

func (seq *Sequence) ParseGroups(idx int, count int, f *bufio.Reader)

func (*Sequence) SetFixedIntonationParams

func (seq *Sequence) SetFixedIntonationParams(pitch, pretonicRange, pretonicLift, tonicRange, tonicMovement float64)

func (*Sequence) SetFullTimeScale

func (seq *Sequence) SetFullTimeScale()

func (*Sequence) SetRadiusCoefs

func (seq *Sequence) SetRadiusCoefs(values []float64)

func (*Sequence) SetZeroRef

func (seq *Sequence) SetZeroRef(nv int)

func (*Sequence) SlopeRatioEvents

func (seq *Sequence) SlopeRatioEvents(evIdx int, sr *SlopeRatio, baseline, paramDelta, min, max float64) float64

type Slope

type Slope struct {
	PointOrSlope
	Slope       float64 `xml:"slope,attr"`
	DisplayTime float64 `xml:"display-time,attr"`
}

func NewSlope

func NewSlope() *Slope

func (*Slope) IsSlopeRatio

func (pos *Slope) IsSlopeRatio() bool

type SlopeRatio

type SlopeRatio struct {
	PointOrSlope
	Points []*Point `xml:"points>point"`
	Slopes []*Slope `xml:"slopes>slope"`
}

func NewSlopeRatio

func NewSlopeRatio() *SlopeRatio

func (*SlopeRatio) IsSlopeRatio

func (sr *SlopeRatio) IsSlopeRatio() bool

func (*SlopeRatio) NSlopeUnits

func (sr *SlopeRatio) NSlopeUnits() float64

type Symbol

type Symbol struct {
	Name    string  `xml:"name,attr"`
	Min     float64 `xml:"minimum,attr."`
	Max     float64 `xml:"maximum,attr"`
	Default float64 `xml:"default,attr"`
	Comment string  `xml:"comment,attr"`
}

func (*Symbol) Set

func (sym *Symbol) Set(nm string, min, max, dflt float64, comment string)

type SymbolType

type SymbolType int

type Target

type Target struct {
	Name  string  `xml:"name,attr"`
	Value float64 `xml:"value,attr"`
}

type ThreeWayJunction

type ThreeWayJunction int32

ThreeWayJunction for the three-way junction alpha coefficients

type ToneGroup

type ToneGroup struct {
	StartFoot int
	EndFoot   int
	Type      ToneType
}

func (*ToneGroup) Defaults

func (tn *ToneGroup) Defaults()

type ToneType

type ToneType int

ToneType

const (
	// ToneStatement
	ToneStatement ToneType = iota

	// ToneExclamation
	ToneExclamation

	// ToneQuestion
	ToneQuestion

	// ToneContinuation
	ToneContinuation

	// ToneSemicolon
	ToneSemicolon

	ToneTypeN
)

type TractCtrl

type TractCtrl struct {
	GlotPitch float64                   `` /* 137-byte string literal not displayed */
	GlotVol   float64                   `min:"0" max:"60" desc:"glottal volume (DB?) typically 60 when present and 0 when not, and sometimes 54, 43.5, 42, "`
	AspVol    float64                   `min:"0" max:"10" desc:"aspiration volume -- typically 0 when not present and 10 when present"`
	FricVol   float64                   `min:"0" max:"24" desc:"fricative volume -- typically 0 or .25 .4, .5, .8 but 24 for ph"`
	FricPos   float64                   `min:"1" max:"7" desc:"ficative position -- varies continuously between 1-7"`
	FricCf    float64                   `` /* 136-byte string literal not displayed */
	FricBw    float64                   `min:"500" max:"4500" desc:"fricative bw seems like a frequency -- common intermediate values are 600, 900, 2000, 2600"`
	Radii     [OroPharynxRegCnt]float64 `desc:"Radii 2-8 radius of pharynx vocal tract segment as determined by tongue etc -- typically around 1, ranging .5 - 1.7"`
	Velum     float64                   `min:".1" max:"1.5" desc:"velum opening -- 1.5 when fully open, .1 when closed, and .25, .5 intermediates used"`
}

ToDo: desc for all Radii

func (*TractCtrl) SetFromParams

func (vtc *TractCtrl) SetFromParams(src *TractCtrl)

SetFromParams fast copy of parameters from other control params

func (*TractCtrl) SetFromValues

func (vtc *TractCtrl) SetFromValues(values []float64)

SetFromValues - order must be preserved!

func (*TractCtrl) UpdateFromDeltas

func (vtc *TractCtrl) UpdateFromDeltas(deltas *TractCtrl)

UpdateFromDeltas updates values in this set of params from deltas

type TractParams

type TractParams struct {
	Temp         float64
	Loss         float64
	MouthCoef    float64
	NoseCoef     float64
	ThroatCutoff float64
	ThroatVol    float64
	VtlOff       float64
	MixOff       float64
	WaveForm     int32
	NoiseMod     bool
}

func (*TractParams) Defaults

func (vtc *TractParams) Defaults()

Defaults sets the default values for the vocal tract

type TransGrp

type TransGrp struct {
	Name        string        `xml:"name,attr"`
	Transitions []*Transition `xml:"transition"`
}

type TransGrps

type TransGrps struct {
	Grps []*TransGrp `xml:"transitions>transition-group"`
}

func (*TransGrps) UnmarshalXML

func (grps *TransGrps) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type TransGrpsSp

type TransGrpsSp struct {
	Grps []*TransGrp `xml:"special-transitions>transition-group"`
}

func (*TransGrpsSp) UnmarshalXML

func (grps *TransGrpsSp) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Transition

type Transition struct {
	Name      string         `xml:"name,attr"`
	Type      TransitionType `xml:"type,attr"`
	PtSlpList []interface{}  `xml:"point-or-slopes>slope-ratio>points>point"`
	Comment   string         `xml:"comment"`
}

Transition

type TransitionType

type TransitionType int

TransitionType

const (
	// TransInvalid
	TransInvalid TransitionType = iota

	// TransDiPhone
	TransDiPhone

	// TransTriPhone
	TransTriPhone

	// TransTetraPhone
	TransTetraPhone

	TransTypeN
)

type TrmConfig

type TrmConfig struct {
	OutputRate float64 `desc:"output sample rate (22.05, 44.1)"`
	Volume     float64 `desc:"master volume (0 - 60 dB)"`
	Channels   int     `desc:"# of sound output channels (1, 2)"`
	Balance    float64 `desc:"stereo balance (-1 to +1)"`
	Waveform   float64 `desc:"GS waveform type (0=PULSE, 1=SINE)"`

	VtlOffset   float64 `desc:"tube length offset"`
	Temperature float64 `desc:"tube temperature (25 - 40 C)"`
	LossFactor  float64 `desc:"junction loss factor in (0 - 5 %)"`

	MouthCoef    float64 `desc:"mouth aperture coefficient"`
	NoseCoef     float64 `desc:"nose aperture coefficient"`
	ThroatCutoff float64 `desc:"throat lp cutoff (50 - nyquist Hz)"`
	ThroatVolume float64 `desc:"throat volume (0 - 48 dB)"`

	NoiseModulation int     `desc:"pulse mod. of noise (0=OFF, 1=ON)"`
	MixOffset       float64 `desc:"noise crossmix offset (30 - 60 dB)"`

	// Parameters that depend on the voice.
	GlottalPulseTp    float64 `desc:"% glottal pulse rise time"`
	GlottalPulseTnMin float64 `desc:"% glottal pulse fall time minimum"`
	GlottalPulseTnMax float64 `desc:"% glottal pulse fall time maximum"`
	Breathiness       float64 `desc:"% glottal source breathiness"`
	VocalTractLength  float64
	RefGlottalPitch   float64
	ApertureRadius    float64 `desc:"aperture scl. radius (3.05 - 12 cm)"`

	// ToDo: nose sections should be a lookup
	NoseRadii []float64 `desc:"fixed nose radii (0 - 3 cm)"`
	// ToDo: also shouldn't be hardcoded
	RadiusCoefs          []float64
	GlobalRadiusCoef     float64
	GlobalNoseRadiusCoef float64
}

func NewTrmConfig

func NewTrmConfig() *TrmConfig

NewTrmConfig creates and returns a TrmConfig struct after making slices for NoseRadii and RadiusCoefs

func (*TrmConfig) Load

func (trm *TrmConfig) Load(pathTrm, pathVoice string)

Load will be passed data/en/trm_control_model.config or equivalent file

func (*TrmConfig) OpenJSON

func (trm *TrmConfig) OpenJSON(fn string) error

OpenJSON opens model config from a JSON-formatted file (i.e. model params)

type Tube

type Tube struct {
	Buf        sound.Wave   `desc:""`
	Volume     float64      `desc:""`
	Balance    float64      `desc:""`
	Duration   float64      `desc:""` // duration of synthesized sound
	Params     TractParams  `desc:""`
	Voice      VoiceParams  `desc:""`
	Dictionary etable.Table `desc:""`
	TrmParams  []TractCtrl  `desc:"all of the trm params read from the trmParamFile"`

	// derived values
	CtrlRate   float64 `desc:""` // 1.0-1000.0 input tables/second (Hz)
	CtrlPeriod int     `desc:""`
	SampleRate int     `desc:""`
	TubeLength float64 `desc:""` // actual length in cm

	CurData  TractCtrl `desc:""` // current control data
	CurDelta TractCtrl `desc:""` // current control data

	// tube and tube coefficients
	Oropharynx      [OroPharynxSectCnt][2][2]float64
	OropharynxCoefs [OroPharynxCoefCnt]float64
	Nasal           [NasalSectCnt][2][2]float64
	NasalCoefs      [NasalCoefCnt]float64
	Alpha           [ThreeWayCnt]float64
	CurPtr          int
	PrvPtr          int

	// memory for frication taps
	FricationTap [FricationInjCoefCnt]float64

	DampingFactor    float64 // calculated
	CrossmixFactor   float64 //  calculated
	BreathFactor     float64
	PrvGlotAmplitude float64

	SynthOutput []float64
	Wave        []float64

	RateConverter         trm.RateConverter
	MouthRadiationFilter  trm.RadiationFilter
	MouthReflectionFilter trm.ReflectionFilter
	NasalRadiationFilter  trm.RadiationFilter
	NasalReflectionFilter trm.ReflectionFilter
	Throat                trm.Throat
	GlottalSource         trm.WavetableGlottalSource
	BandpassFilter        trm.BandpassFilter
	NoiseFilter           trm.NoiseFilter
	NoiseSource           trm.NoiseSource
}

func NewTube

func NewTube() *Tube

Init gets us going - this is the first function to call

func (*Tube) InitNasal

func (tube *Tube) InitNasal()

InitNasalCavity

func (*Tube) InitSndBuf

func (tube *Tube) InitSndBuf(frames int, channels, rate, bitDepth int)

InitBuffer

func (*Tube) InitSynth

func (tube *Tube) InitSynth()

func (*Tube) InitializeSynthesizer

func (tube *Tube) InitializeSynthesizer()

InitializeSynthesizer initializes all variables so that the synthesis can be run

func (*Tube) MonoScale

func (tube *Tube) MonoScale() float64

MonoScale

func (*Tube) ParseTrmFile

func (tube *Tube) ParseTrmFile(fn string)

ParseTrmFile trm parameter file, order is fixed!

func (*Tube) RateInterpolation

func (tube *Tube) RateInterpolation()

RateInterpolation interpolates table values at the sample rate

func (*Tube) Reset

func (tube *Tube) Reset()

Reset reset all vocal tract values

func (*Tube) ResizeSndBuf

func (tube *Tube) ResizeSndBuf(frames int)

InitBuffer

func (*Tube) SetCtrlParams

func (tube *Tube) SetCtrlParams(idx int)

SetCtrlParams calculates the current table values, and their associated sample-to-sample delta values.

func (*Tube) SetFricationTaps

func (tube *Tube) SetFricationTaps()

SetFricationTaps Sets frication taps according to the current position and amplitude of frication

func (*Tube) StereoScale

func (tube *Tube) StereoScale(leftScale,
	rightScale *float64)

StereoScale

func (*Tube) SynthReset

func (tube *Tube) SynthReset(initBuffer bool)

SynthReset

func (*Tube) SynthSignal

func (tube *Tube) SynthSignal()

SynthSignal

func (*Tube) SynthToFile

func (tube *Tube) SynthToFile(trmParamFile, outFile string)

SynthToFile

func (*Tube) SynthTrmInput

func (tube *Tube) SynthTrmInput()

SynthTrmInput synthesizes from the trm parameter data

func (*Tube) TubeCoefficients

func (tube *Tube) TubeCoefficients()

TubeCoefficients calculates the scattering coefficients for the vocal tract according to the current radii. Also calculates the coefficients for the reflection/radiation filter pairs for the mouth and nose.

func (*Tube) VocalTract

func (tube *Tube) VocalTract(input, frication float64) (output float64)

Update updates the pressure wave throughout the vocal tract, and returns the summed output of the oral and nasal cavities. Also injects frication appropriately

type VoiceParams

type VoiceParams struct {
	TractLength      float64    `desc:"length of vocal tract - shortest for baby voice, longest for male voice"`
	GlotPulseFallMin float64    `desc:"glottal pulse is the rate at which the vocal folds of the glottis open and close - not sure about FallMin/FallMax"`
	GlotPulseFallMax float64    `desc:"glottal pulse is the rate at which the vocal folds of the glottis open and close - not sure about FallMin/FallMax"`
	GlotPitchRef     float64    `desc:"the pitch of the voice is usually set by the frequency of glottal pulses during vowels or voiced consonants"`
	Breath           float64    `desc:"how much air escapes on each glottal pulse, more for female voices"`
	GlotPulseRise    float64    `desc:"glottal pulse is the rate at which the vocal folds of the glottis open and close - not sure about rise"`
	ApertureRadius   float64    `desc:""`
	NoseRadii        [6]float64 `desc:"fixed nose radii (0 - 3 cm)"`
	NoseRadiusCoef   float64    `desc:"global nose radius coefficient"`
	RadiusCoef       float64    `desc:""`
}

VoiceParams are the parameters that control the quality of the voice

func (*VoiceParams) Defaults

func (vp *VoiceParams) Defaults()

DefaultParams are the defaults, some of which don't change

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL