Class: Voicevox::AccentPhrase

Inherits:
Object
  • Object
show all
Defined in:
lib/voicevox/wrapper/audio_query.rb

Overview

アクセント句ごとの情報。

Defined Under Namespace

Classes: Mora

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ AccentPhrase

Returns a new instance of AccentPhrase.



149
150
151
152
153
154
# File 'lib/voicevox/wrapper/audio_query.rb', line 149

def initialize(query)
  @moras = query[:moras].map { |ap| Mora.new ap }
  @accent = query[:accent]
  @pause_mora = query[:pause_mora] && Mora.new(query[:pause_mora])
  @is_interrogative = query[:is_interrogative]
end

Instance Attribute Details

#accentInteger (readonly)

Returns アクセント箇所。.

Returns:

  • (Integer)

    アクセント箇所。



142
143
144
# File 'lib/voicevox/wrapper/audio_query.rb', line 142

def accent
  @accent
end

#is_interrogativeBoolean (readonly) Also known as: interrogative?

Returns 疑問系かどうか。.

Returns:

  • (Boolean)

    疑問系かどうか。



146
147
148
# File 'lib/voicevox/wrapper/audio_query.rb', line 146

def is_interrogative
  @is_interrogative
end

#morasArray<Mora> (readonly)

Returns モーラのリスト。.

Returns:

  • (Array<Mora>)

    モーラのリスト。



140
141
142
# File 'lib/voicevox/wrapper/audio_query.rb', line 140

def moras
  @moras
end

#pause_moraMora? (readonly)

Returns 後ろに無音を付けるかどうか。.

Returns:

  • (Mora, nil)

    後ろに無音を付けるかどうか。



144
145
146
# File 'lib/voicevox/wrapper/audio_query.rb', line 144

def pause_mora
  @pause_mora
end

Instance Method Details

#to_hashHash

AccentPhraseをHashにします。

Returns:

  • (Hash)


161
162
163
164
165
166
167
168
# File 'lib/voicevox/wrapper/audio_query.rb', line 161

def to_hash
  {
    moras: @moras.map(&:to_hash),
    accent: @accent,
    pause_mora: @pause_mora&.to_hash,
    is_interrogative: @is_interrogative
  }
end