voicevox.rb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +19 -0
- data/LICENSE +21 -0
- data/README.md +46 -0
- data/Rakefile +7 -0
- data/Steepfile +29 -0
- data/examples/cli.rb +48 -0
- data/examples/outputs/.gitkeep +0 -0
- data/examples/repl_core.rb +48 -0
- data/examples/repl_wrapper.rb +33 -0
- data/lib/voicevox/core.rb +448 -0
- data/lib/voicevox/error.rb +79 -0
- data/lib/voicevox/version.rb +6 -0
- data/lib/voicevox/wrapper/audio_query.rb +213 -0
- data/lib/voicevox/wrapper/info.rb +113 -0
- data/lib/voicevox/wrapper/manager.rb +137 -0
- data/lib/voicevox/wrapper/utils.rb +45 -0
- data/lib/voicevox.rb +15 -0
- data/rbs_collection.lock.yaml +100 -0
- data/rbs_collection.yaml +15 -0
- data/sig/ffi.rbs +16 -0
- data/sig/voicevox/core.rbs +126 -0
- data/sig/voicevox/error.rbs +53 -0
- data/sig/voicevox/wrapper/info.rbs +26 -0
- data/sig/voicevox/wrapper/manager.rbs +31 -0
- data/sig/voicevox/wrapper/utils.rbs +9 -0
- data/sig/voicevox.rbs +3 -0
- data/voicevox.gemspec +42 -0
- metadata +88 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
module Voicevox::Core
|
2
|
+
extend FFI::Library
|
3
|
+
|
4
|
+
type voicevox_result_code =
|
5
|
+
:voicevox_result_succeed
|
6
|
+
| :voicevox_result_not_loaded_openjtalk_dict
|
7
|
+
| :voicevox_result_failed_load_model
|
8
|
+
| :voicevox_result_failed_get_supported_devices
|
9
|
+
| :voicevox_result_cant_gpu_support
|
10
|
+
| :voicevox_result_failed_load_metas
|
11
|
+
| :voicevox_result_uninitialized_status
|
12
|
+
| :voicevox_result_invalid_speaker_id
|
13
|
+
| :voicevox_result_invalid_model_index
|
14
|
+
| :voicevox_result_inference_failed
|
15
|
+
| :voicevox_result_failed_extract_full_context_label
|
16
|
+
| :voicevox_result_invalid_utf8_input
|
17
|
+
| :voicevox_result_failed_parse_kana
|
18
|
+
| :voicevox_result_invalid_audio_query
|
19
|
+
|
20
|
+
type voicevox_acceleration_mode =
|
21
|
+
:voicevox_acceleration_mode_auto
|
22
|
+
| :voicevox_acceleration_mode_cpu
|
23
|
+
| :voicevox_acceleration_mode_gpu
|
24
|
+
|
25
|
+
class VoicevoxInitializeOptions < FFI::Struct
|
26
|
+
attr_accessor acceleration_mode: voicevox_acceleration_mode
|
27
|
+
attr_accessor cpu_num_threads: Integer
|
28
|
+
attr_accessor load_all_models: bool
|
29
|
+
attr_accessor openjtalk_dict_path: String
|
30
|
+
end
|
31
|
+
|
32
|
+
class VoicevoxAudioQueryOptions < FFI::Struct
|
33
|
+
attr_accessor kana: bool
|
34
|
+
end
|
35
|
+
|
36
|
+
class VoicevoxSynthesisOptions < FFI::Struct
|
37
|
+
attr_accessor enable_interrogative_upspeak: bool
|
38
|
+
end
|
39
|
+
|
40
|
+
class VoicevoxTtsOptions < FFI::Struct
|
41
|
+
attr_accessor kana: bool
|
42
|
+
attr_accessor enable_interrogative_upspeak: bool
|
43
|
+
end
|
44
|
+
|
45
|
+
def self?.voicevox_make_default_initialize_options: -> Voicevox::VoicevoxInitializeOptions
|
46
|
+
|
47
|
+
def self?.voicevox_initialize: (
|
48
|
+
VoicevoxInitializeOptions options
|
49
|
+
) -> voicevox_result_code
|
50
|
+
|
51
|
+
def self?.voicevox_load_model: (Integer speaker_id) -> bool
|
52
|
+
|
53
|
+
def self?.voicevox_is_gpu_mode: -> bool
|
54
|
+
|
55
|
+
def self?.voicevox_is_model_loaded: (Integer speaker_id) -> bool
|
56
|
+
|
57
|
+
def self?.voicevox_finalize: -> void
|
58
|
+
|
59
|
+
def self?.voicevox_get_metas_json: -> String
|
60
|
+
|
61
|
+
def self?.voicevox_get_supported_devices_json: -> String
|
62
|
+
|
63
|
+
def self?.voicevox_last_error_message: -> String
|
64
|
+
|
65
|
+
def self?.voicevox_predict_duration: (
|
66
|
+
Integer length,
|
67
|
+
FFI::Pointer phoneme_list,
|
68
|
+
FFI::Pointer speaker_id,
|
69
|
+
FFI::Pointer output
|
70
|
+
) -> bool
|
71
|
+
|
72
|
+
def self?.voicevox_predict_intonation: (
|
73
|
+
Integer length,
|
74
|
+
FFI::Pointer vowel_phoneme_list,
|
75
|
+
FFI::Pointer consonant_phoneme_list,
|
76
|
+
FFI::Pointer start_accent_list,
|
77
|
+
FFI::Pointer end_accent_list,
|
78
|
+
FFI::Pointer start_accent_phrase_list,
|
79
|
+
FFI::Pointer end_accent_phrase_list,
|
80
|
+
Integer speaker_id,
|
81
|
+
FFI::Pointer output
|
82
|
+
) -> bool
|
83
|
+
|
84
|
+
def self?.voicevox_decode: (
|
85
|
+
Integer length,
|
86
|
+
Integer phoneme_size,
|
87
|
+
FFI::Pointer f0,
|
88
|
+
FFI::Pointer phoneme,
|
89
|
+
Integer speaker_id,
|
90
|
+
FFI::Pointer output
|
91
|
+
) -> bool
|
92
|
+
|
93
|
+
def self?.voicevox_make_default_audio_query_options: -> Voicevox::VoicevoxAudioQueryOptions
|
94
|
+
|
95
|
+
def self?.voicevox_audio_query: (
|
96
|
+
String text,
|
97
|
+
Integer speaker_id,
|
98
|
+
VoicevoxAudioQueryOptions options,
|
99
|
+
FFI::Pointer output
|
100
|
+
) -> voicevox_result_code
|
101
|
+
|
102
|
+
def self?.voicevox_synthesis: (
|
103
|
+
String audio_query_json,
|
104
|
+
Integer speaker_id,
|
105
|
+
VoicevoxSynthesisOptions options,
|
106
|
+
FFI::Pointer output_wav_size,
|
107
|
+
FFI::Pointer output_wav
|
108
|
+
) -> voicevox_result_code
|
109
|
+
|
110
|
+
def self?.voicevox_make_default_tts_options: -> Voicevox::VoicevoxTtsOptions
|
111
|
+
|
112
|
+
def self?.voicevox_tts: (
|
113
|
+
String text,
|
114
|
+
String speaker_id,
|
115
|
+
VoicevoxTtsOptions options,
|
116
|
+
FFI::Pointer output_binary_size,
|
117
|
+
FFI::Pointer output_wav
|
118
|
+
) -> voicevox_result_code
|
119
|
+
|
120
|
+
def self?.voicevox_audio_query_json_free: (FFI::Pointer wav) -> void
|
121
|
+
def self?.voicevox_wav_free: (FFI::Pointer wav) -> void
|
122
|
+
|
123
|
+
def self?.voicevox_error_result_to_message: (
|
124
|
+
voicevox_result_code result_code
|
125
|
+
) -> String
|
126
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class Voicevox
|
2
|
+
class Error < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
class CoreError < Error
|
6
|
+
attr_reader code: Voicevox::Core::voicevox_result_code
|
7
|
+
|
8
|
+
attr_reader self.code: Voicevox::Core::voicevox_result_code
|
9
|
+
|
10
|
+
def initialize: -> void
|
11
|
+
|
12
|
+
def self.from_code: (Voicevox::Core::voicevox_result_code code) -> CoreError
|
13
|
+
|
14
|
+
class NotLoadedOpenjtalkDict < Voicevox::CoreError
|
15
|
+
end
|
16
|
+
|
17
|
+
class FailedLoadModel < Voicevox::CoreError
|
18
|
+
end
|
19
|
+
|
20
|
+
class FailedGetSupportedDevices < Voicevox::CoreError
|
21
|
+
end
|
22
|
+
|
23
|
+
class CantGpuSupport < Voicevox::CoreError
|
24
|
+
end
|
25
|
+
|
26
|
+
class FailedLoadMetas < Voicevox::CoreError
|
27
|
+
end
|
28
|
+
|
29
|
+
class UninitializedStatus < Voicevox::CoreError
|
30
|
+
end
|
31
|
+
|
32
|
+
class InvalidSpeakerId < Voicevox::CoreError
|
33
|
+
end
|
34
|
+
|
35
|
+
class InvalidModelIndex < Voicevox::CoreError
|
36
|
+
end
|
37
|
+
|
38
|
+
class InferenceFailed < Voicevox::CoreError
|
39
|
+
end
|
40
|
+
|
41
|
+
class FailedExtractFullContextLabel < Voicevox::CoreError
|
42
|
+
end
|
43
|
+
|
44
|
+
class InvalidUtf8Input < Voicevox::CoreError
|
45
|
+
end
|
46
|
+
|
47
|
+
class FailedParseKana < Voicevox::CoreError
|
48
|
+
end
|
49
|
+
|
50
|
+
class InvalidAudioQuery < Voicevox::CoreError
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Voicevox
|
2
|
+
def self.supported_devices: -> Voicevox::SupportedDevices
|
3
|
+
def self.characters: -> Array[Voicevox::CharacterInfo]
|
4
|
+
|
5
|
+
class SupportedDevices < Struct[bool]
|
6
|
+
attr_accessor cpu: bool
|
7
|
+
attr_accessor cuda: bool
|
8
|
+
attr_accessor dml: bool
|
9
|
+
end
|
10
|
+
|
11
|
+
class CharacterInfo < Struct[untyped]
|
12
|
+
attr_accessor name: String
|
13
|
+
attr_accessor styles: Array[Voicevox::StyleInfo]
|
14
|
+
attr_accessor speaker_uuid: String
|
15
|
+
attr_accessor version: String
|
16
|
+
end
|
17
|
+
|
18
|
+
class StyleInfo < Struct[untyped]
|
19
|
+
attr_accessor name: String
|
20
|
+
attr_accessor id: Integer
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.gpu_supported?: -> bool
|
24
|
+
|
25
|
+
def self.core_version: -> String
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Voicevox
|
2
|
+
attr_reader use_gpu: bool
|
3
|
+
attr_reader threads: Integer
|
4
|
+
attr_reader load_all_models: bool
|
5
|
+
|
6
|
+
alias gpu? use_gpu
|
7
|
+
|
8
|
+
def initialize: (
|
9
|
+
String openjtalk_dict_path,
|
10
|
+
?use_gpu: :auto | bool,
|
11
|
+
?threads: Integer?,
|
12
|
+
?load_all_models: bool
|
13
|
+
) -> void
|
14
|
+
|
15
|
+
def finalize: -> void
|
16
|
+
|
17
|
+
def load_openjtalk_dict: (String path) -> void
|
18
|
+
|
19
|
+
type speaker = Voicevox::CharacterInfo | Voicevox::StyleInfo | Integer
|
20
|
+
|
21
|
+
def load_model: (speaker speaker) -> void
|
22
|
+
def model_loaded?: (speaker speaker) -> bool
|
23
|
+
|
24
|
+
def tts: (String text, speaker speaker) -> String
|
25
|
+
def tts_from_kana: (String text, speaker speaker) -> String
|
26
|
+
alias aquestalk_tts tts_from_kana
|
27
|
+
|
28
|
+
attr_accessor self.initialized: bool
|
29
|
+
|
30
|
+
alias self.initialized? self.initialized
|
31
|
+
end
|
data/sig/voicevox.rbs
ADDED
data/voicevox.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/voicevox/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "voicevox.rb"
|
7
|
+
spec.version = Voicevox::VERSION
|
8
|
+
spec.authors = ["sevenc-nanashi"]
|
9
|
+
spec.email = ["sevenc7c@sevenc7c.com"]
|
10
|
+
|
11
|
+
spec.summary = "Unofficial wrapper for voicevox_core"
|
12
|
+
spec.homepage = "https://github.com/sevenc-nanashi/voicevox.rb"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = ">= 3.0.0"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
18
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files =
|
23
|
+
Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0")
|
25
|
+
.reject do |f|
|
26
|
+
(f == __FILE__) ||
|
27
|
+
f.match(
|
28
|
+
%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)}
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
# Uncomment to register a new dependency of your gem
|
37
|
+
spec.add_dependency("ffi", "~> 1.15")
|
38
|
+
|
39
|
+
# For more information and examples about making a new gem, check out our
|
40
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
41
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: voicevox.rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sevenc-nanashi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- sevenc7c@sevenc7c.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rubocop.yml"
|
35
|
+
- CHANGELOG.md
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- Steepfile
|
41
|
+
- examples/cli.rb
|
42
|
+
- examples/outputs/.gitkeep
|
43
|
+
- examples/repl_core.rb
|
44
|
+
- examples/repl_wrapper.rb
|
45
|
+
- lib/voicevox.rb
|
46
|
+
- lib/voicevox/core.rb
|
47
|
+
- lib/voicevox/error.rb
|
48
|
+
- lib/voicevox/version.rb
|
49
|
+
- lib/voicevox/wrapper/audio_query.rb
|
50
|
+
- lib/voicevox/wrapper/info.rb
|
51
|
+
- lib/voicevox/wrapper/manager.rb
|
52
|
+
- lib/voicevox/wrapper/utils.rb
|
53
|
+
- rbs_collection.lock.yaml
|
54
|
+
- rbs_collection.yaml
|
55
|
+
- sig/ffi.rbs
|
56
|
+
- sig/voicevox.rbs
|
57
|
+
- sig/voicevox/core.rbs
|
58
|
+
- sig/voicevox/error.rbs
|
59
|
+
- sig/voicevox/wrapper/info.rbs
|
60
|
+
- sig/voicevox/wrapper/manager.rbs
|
61
|
+
- sig/voicevox/wrapper/utils.rbs
|
62
|
+
- voicevox.gemspec
|
63
|
+
homepage: https://github.com/sevenc-nanashi/voicevox.rb
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata:
|
67
|
+
homepage_uri: https://github.com/sevenc-nanashi/voicevox.rb
|
68
|
+
rubygems_mfa_required: 'true'
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.0.0
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubygems_version: 3.4.1
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Unofficial wrapper for voicevox_core
|
88
|
+
test_files: []
|