intermediate plumbing for new vocoders

This commit is contained in:
Brandon Thomas committed 2021-08-25 01:11:36 -04:00
1 parent c9112b7714
commit 21cffc1f03
6 files changed
+100 -33

No files matched your search

+2 -1
View File
@@ -1 +1,2 @@
pub mod record_visibility;
pub mod record_visibility;
pub mod vocoder_type;
+29
View File
@@ -0,0 +1,29 @@
//! These denote the pretrained vocoders
use anyhow::anyhow;
use crate::util::anyhow_result::AnyhowResult;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, sqlx::Type)]
#[serde(rename_all = "lowercase")]
#[sqlx(rename_all = "lowercase")]
pub enum VocoderType {
HifiGanSuperSample,
WaveGlow,
}
impl VocoderType {
pub fn to_str(&self) -> &'static str {
match self {
VocoderType::HifiGanSuperSample => "hifigan-supersample",
VocoderType::WaveGlow => "waveglow",
}
}
pub fn from_str(vocoder_type: &str) -> AnyhowResult<Self> {
match vocoder_type {
"hifigan-supersample" => Ok(VocoderType::HifiGanSuperSample),
"waveglow" => Ok(VocoderType::WaveGlow),
_ => Err(anyhow!("invalid value: {:?}", vocoder_type)),
}
}
}