mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 08:57:54 +00:00
rust warnings cleanup
This commit is contained in:
1 parent
a862124dc5
commit
83a4bb919d
12 files changed
+19
-60
No files matched your search
@@ -1,5 +1,5 @@
|
||||
use anyhow::Result as AnyhowResult;
|
||||
use chrono::{NaiveDateTime, DateTime, Utc};
|
||||
use chrono::NaiveDateTime;
|
||||
use crate::database::connector::{DatabaseConnector, MysqlPooledConnection};
|
||||
use crate::schema::sentences;
|
||||
//use crate::schema::sentences::dsl::*;
|
||||
|
||||
@@ -3,18 +3,15 @@ use actix_web::web::{Data, Query};
|
||||
use actix_web::{
|
||||
HttpRequest,
|
||||
HttpResponse,
|
||||
get,
|
||||
};
|
||||
|
||||
use std::sync::Arc;
|
||||
use crate::AppState;
|
||||
use arpabet::Arpabet;
|
||||
use crate::text::text_to_arpabet_encoding;
|
||||
use crate::config::{Speaker, ModelPipeline};
|
||||
use crate::model::arpabet_tacotron_model::ArpabetTacotronModel;
|
||||
use crate::config::ModelPipeline;
|
||||
use crate::model::old_model::TacoMelModel;
|
||||
use crate::database::model::NewSentence;
|
||||
use anyhow::Error;
|
||||
|
||||
/// Example request: v=trump&vol=3&s=this is funny isn't it
|
||||
#[derive(Deserialize)]
|
||||
|
||||
@@ -3,13 +3,11 @@ use actix_web::web::{
|
||||
Json,
|
||||
};
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::{HttpRequest, get, HttpResponse, Responder, Either};
|
||||
use actix_web::{HttpRequest, get, HttpResponse, Either};
|
||||
|
||||
use std::sync::Arc;
|
||||
use crate::AppState;
|
||||
use crate::config::{ModelConfigs, Speaker};
|
||||
use crate::database::model::Sentence;
|
||||
use anyhow::Error;
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct SentencesResult {
|
||||
|
||||
@@ -6,7 +6,6 @@ use actix_web::web::{
|
||||
use actix_web::{
|
||||
HttpRequest,
|
||||
HttpResponse,
|
||||
get,
|
||||
};
|
||||
|
||||
use std::sync::Arc;
|
||||
@@ -14,7 +13,7 @@ use crate::AppState;
|
||||
use arpabet::Arpabet;
|
||||
use crate::text::text_to_arpabet_encoding;
|
||||
use crate::model::old_model::TacoMelModel;
|
||||
use crate::config::{Speaker, ModelPipeline};
|
||||
use crate::config::ModelPipeline;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct SpeakRequest {
|
||||
@@ -30,7 +29,7 @@ pub async fn post_speak(_request: HttpRequest,
|
||||
) -> std::io::Result<HttpResponse> {
|
||||
println!("POST /speak");
|
||||
|
||||
let mut app_state = app_state.into_inner();
|
||||
let app_state = app_state.into_inner();
|
||||
|
||||
let speaker = match app_state.model_configs.find_speaker_by_slug(&query.speaker) {
|
||||
Some(speaker) => speaker,
|
||||
|
||||
@@ -9,7 +9,7 @@ use actix_web::{
|
||||
|
||||
use std::sync::Arc;
|
||||
use crate::AppState;
|
||||
use crate::config::{ModelConfigs, Speaker};
|
||||
use crate::config::Speaker;
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
pub struct SpeakersResult {
|
||||
|
||||
@@ -6,7 +6,6 @@ use actix_web::web::{
|
||||
use actix_web::{
|
||||
HttpRequest,
|
||||
HttpResponse,
|
||||
get,
|
||||
};
|
||||
|
||||
use std::sync::Arc;
|
||||
@@ -51,7 +50,7 @@ pub async fn post_tts(_request: HttpRequest,
|
||||
|
||||
println!("Encoded Text: {:?}", encoded);
|
||||
|
||||
let mut app_state = app_state.into_inner();
|
||||
let app_state = app_state.into_inner();
|
||||
|
||||
let tacotron = app_state.model_cache.get_or_load_arbabet_tacotron(&tacotron_model)
|
||||
.expect(&format!("Couldn't load tacotron: {}", &tacotron_model));
|
||||
|
||||
+1
-13
@@ -23,15 +23,11 @@ use std::fmt::Display;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use arpabet::Arpabet;
|
||||
|
||||
use actix_cors::Cors;
|
||||
use actix_files::Files;
|
||||
use actix_web::middleware::Logger;
|
||||
use actix_web::web::Json;
|
||||
use actix_web::{App, HttpResponse, HttpServer, web, http};
|
||||
use anyhow::{Result as AnyhowResult, Error};
|
||||
use dotenv::dotenv;
|
||||
use anyhow::Result as AnyhowResult;
|
||||
|
||||
use crate::config::ModelConfigs;
|
||||
use crate::endpoints::index::get_root;
|
||||
@@ -43,8 +39,6 @@ use crate::endpoints::speak::post_speak;
|
||||
use crate::endpoints::speakers::get_speakers;
|
||||
use crate::endpoints::tts::post_tts;
|
||||
use crate::model::model_cache::ModelCache;
|
||||
use crate::model::old_model::TacoMelModel;
|
||||
use crate::text::text_to_arpabet_encoding;
|
||||
use crate::database::connector::DatabaseConnector;
|
||||
use crate::endpoints::sentences::get_sentences;
|
||||
|
||||
@@ -60,12 +54,6 @@ const DEFAULT_MODEL_CONFIG_FILE: &'static str = "models.toml";
|
||||
const DEFAULT_RUST_LOG: &'static str = "debug,actix_web=info";
|
||||
const DEFAULT_NUM_WORKERS : usize = 4;
|
||||
|
||||
/// For query strings
|
||||
#[derive(Deserialize)]
|
||||
pub struct TtsQueryRequest {
|
||||
text: String,
|
||||
}
|
||||
|
||||
/** State that is easy to pass between handlers. */
|
||||
pub struct AppState {
|
||||
pub model_configs: ModelConfigs,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::model::model_container::ModelContainer;
|
||||
use anyhow::Result;
|
||||
use tch::Tensor;
|
||||
use std::path::Path;
|
||||
use std::sync::{Mutex, MutexGuard, TryLockError};
|
||||
use std::time::Duration;
|
||||
use std::sync::Mutex;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use tch::Tensor;
|
||||
|
||||
pub struct ArpabetTacotronModel {
|
||||
model_container: Mutex<ModelContainer>,
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
use anyhow::Error;
|
||||
use crate::model::arpabet_tacotron_model::ArpabetTacotronModel;
|
||||
use crate::model::melgan_model::MelganModel;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use crate::config::{ModelType, ModelLocation};
|
||||
use crate::config::ModelType::ArpabetTacotron;
|
||||
use std::path::{PathBuf, Path};
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub struct ModelCache {
|
||||
/// Base directories for each model type(if configured)
|
||||
|
||||
@@ -2,7 +2,6 @@ use anyhow::Result;
|
||||
use tch::CModule;
|
||||
use tch::Tensor;
|
||||
use tch::nn::Module;
|
||||
use tch::nn::ModuleT;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Holds the loaded pytorch JIT model
|
||||
|
||||
@@ -1,28 +1,16 @@
|
||||
use hound::SampleFormat;
|
||||
use hound::WavSpec;
|
||||
use hound::WavWriter;
|
||||
|
||||
use tch::{CModule, Kind};
|
||||
use tch::Tensor;
|
||||
use tch::nn::Module;
|
||||
use tch::nn::ModuleT;
|
||||
|
||||
use std::io::Cursor;
|
||||
use std::io::BufWriter;
|
||||
|
||||
use std::io::Cursor;
|
||||
use tch::Tensor;
|
||||
use crate::model::arpabet_tacotron_model::ArpabetTacotronModel;
|
||||
use crate::model::model_container::ModelContainer;
|
||||
use crate::model::melgan_model::MelganModel;
|
||||
|
||||
pub struct TacoMelModel {
|
||||
}
|
||||
|
||||
impl TacoMelModel {
|
||||
fn load_model_file(filename: &str) -> CModule {
|
||||
println!("Loading model: {}", filename);
|
||||
CModule::load(filename).unwrap()
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
@@ -63,7 +51,7 @@ impl TacoMelModel {
|
||||
}
|
||||
|
||||
fn encoded_text_to_audio_signal(&self, tacotron: &ArpabetTacotronModel, melgan: &MelganModel, text_buffer: &Vec<i64>) -> Option<Vec<i16>> {
|
||||
let mut mel_tensor = match tacotron.encoded_arpabet_to_mel(&text_buffer) {
|
||||
let mel_tensor = match tacotron.encoded_arpabet_to_mel(&text_buffer) {
|
||||
None => return None,
|
||||
Some(mel) => mel,
|
||||
};
|
||||
@@ -102,14 +90,10 @@ impl TacoMelModel {
|
||||
}
|
||||
|
||||
fn audio_tensor_to_audio_signal(mel: Tensor) -> Vec<i16> {
|
||||
let mut flat_audio_tensor = mel.squeeze();
|
||||
let flat_audio_tensor = mel.squeeze();
|
||||
|
||||
let length = flat_audio_tensor.size1().unwrap() as usize;
|
||||
let mut data : Vec<f32> = Vec::with_capacity(length);
|
||||
|
||||
for i in 0 .. length {
|
||||
data.push(0.0f32);
|
||||
}
|
||||
let mut data = [0.0f32].repeat(length);
|
||||
|
||||
flat_audio_tensor.copy_data(data.as_mut_slice(), length as usize);
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
use arpabet::Arpabet;
|
||||
use arpabet::phoneme::{Phoneme,VowelStress,Vowel,Consonant};
|
||||
use arpabet::Polyphone;
|
||||
use arpabet::phoneme::Phoneme;
|
||||
use arpabet::extensions::Punctuation as ArpabetPunctuation;
|
||||
use arpabet::extensions::SentenceToken;
|
||||
use sentence::{SentenceTokenizer, Token, Punctuation};
|
||||
use numerics::{NumericsBuilder, Numerics};
|
||||
use std::num::ParseIntError;
|
||||
use numerics::Numerics;
|
||||
|
||||
/// Convert text to the encoding used in Nvidia/Tacotron2 natively.
|
||||
pub fn text_to_standard_encoding(text: &str) -> Vec<i64> {
|
||||
|
||||
Reference in new issue
Block a user