-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
385dd01
commit d7ddce2
Showing
8 changed files
with
156 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::*; | ||
|
||
#[derive(Getters, Debug, Serialize, Deserialize)] | ||
pub struct SupportedDevices { | ||
cpu: bool, | ||
cuda: bool, | ||
dml: bool, | ||
} | ||
|
||
impl SupportedDevices { | ||
/// サポートされているデバイス情報を取得する | ||
pub fn get_supported_devices() -> Result<Self> { | ||
let mut cuda_support = false; | ||
let mut dml_support = false; | ||
for provider in onnxruntime::session::get_available_providers() | ||
.map_err(|e| Error::GetSupportedDevices(e.into()))? | ||
.iter() | ||
{ | ||
match provider.as_str() { | ||
"CUDAExecutionProvider" => cuda_support = true, | ||
"DmlExecutionProvider" => dml_support = true, | ||
_ => {} | ||
} | ||
} | ||
|
||
Ok(SupportedDevices { | ||
cpu: true, | ||
cuda: cuda_support, | ||
dml: dml_support, | ||
}) | ||
} | ||
|
||
pub fn to_json(&self) -> serde_json::Value { | ||
serde_json::to_value(self).expect("should not fail") | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
#[rstest] | ||
fn supported_devices_get_supported_devices_works() { | ||
let result = SupportedDevices::get_supported_devices(); | ||
// 環境によって結果が変わるので、関数呼び出しが成功するかどうかの確認のみ行う | ||
assert!(result.is_ok(), "{:?}", result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use derive_getters::Getters; | ||
use serde::Deserialize; | ||
use std::path::PathBuf; | ||
|
||
pub type RawManifestVersion = String; | ||
#[derive(Deserialize)] | ||
pub struct ManifestVersion(RawManifestVersion); | ||
|
||
#[derive(Deserialize, Getters)] | ||
pub struct Manifest { | ||
manifest_version: ManifestVersion, | ||
decode_file_path: PathBuf, | ||
predict_duration_file_path: PathBuf, | ||
predict_intonation_file_path: PathBuf, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use derive_getters::Getters; | ||
use serde::Deserialize; | ||
|
||
/// スタイルIdの実体 | ||
pub type RawStyleId = usize; | ||
/// スタイルId | ||
#[derive(Deserialize)] | ||
pub struct StyleId(RawStyleId); | ||
|
||
/// スピーカーIdの実体 | ||
pub type RawSpeakerId = usize; | ||
|
||
/// スピーカーId | ||
#[derive(Deserialize)] | ||
pub struct SpeakerId(RawSpeakerId); | ||
|
||
/// 音声合成モデルのメタ情報 | ||
#[derive(Deserialize, Getters)] | ||
pub struct VoiceModelMeta { | ||
speakers: Vec<SpeakerMeta>, | ||
} | ||
|
||
/// スピーカーのメタ情報 | ||
#[derive(Deserialize, Getters)] | ||
pub struct SpeakerMeta { | ||
id: SpeakerId, | ||
name: String, | ||
styles: Vec<StyleMeta>, | ||
version: String, | ||
uuid: String, | ||
} | ||
|
||
/// スタイルのメタ情報 | ||
#[derive(Deserialize, Getters)] | ||
pub struct StyleMeta { | ||
id: StyleId, | ||
name: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use super::*; | ||
use std::path::Path; | ||
|
||
/// 音声合成モデルIdの実体 | ||
pub type RawVoiceModelId = usize; | ||
|
||
/// 音声合成モデルId (型を強く分けるためにこうしている) | ||
pub struct VoiceModelId(RawVoiceModelId); | ||
|
||
/// 音声合成モデル | ||
pub struct VoiceModel {} | ||
|
||
impl VoiceModel { | ||
/// 与えられたパスからモデルを取得する | ||
pub fn from_path(path: impl AsRef<Path>) -> Result<Self> {} | ||
/// ランダムに発行されたこのモデルのIdを返す | ||
pub fn id(&self) -> &VoiceModelId {} | ||
/// このモデルのメタ情報を返す | ||
pub fn metas(&self) -> &VoiceModelMeta {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use super::*; | ||
|
||
/// 音声シンセサイザ | ||
pub struct VoiceSynthesizer {} | ||
impl VoiceSynthesizer { | ||
/// コンストラクタ兼初期化 | ||
pub fn new_with_initialize(options: InitializeOptions) -> Self {} | ||
|
||
/// 音声合成モデルを読み込む | ||
pub fn load_model(&mut self, model: VoiceModel) -> Result<()> {} | ||
|
||
/// 指定したモデルIdの音声合成モデルを開放する | ||
pub fn unload_model(&mut self, model_id: VoiceModelId) -> Result<()> {} | ||
|
||
/// 指定したモデルIdの音声合成モデルが読み込まれているか判定する | ||
pub fn is_loaded_model(&self, model_id: VoiceModelId) -> bool {} | ||
|
||
/// 今読み込んでいる音声合成モデルのメタ情報を返す | ||
pub fn metas(&self) -> &VoiceModelMeta {} | ||
|
||
/// 音声合成を行う | ||
pub fn synthesis(&self, style_id: &StyleId) -> Result<Vec<u8>> {} | ||
} |