holy shit that worked

This commit is contained in:
Brandon Thomas committed 2020-06-03 20:06:20 -04:00
1 parent 9922e5a913
commit a6af26b4df
3 files changed
+80 -4

No files matched your search

+4 -2
View File
@@ -11,7 +11,8 @@ melgan = "melgan_trump_txlearn_2020-05-30_steno_chkpt9800.torchjit"
name = "Donald Trump (Glow-TTS experiments)"
slug = "trump2"
model_pipeline = "ArpabetGlowTtsMelgan"
glow_tts = "glow-experimental.torchjit"
#glow_tts = "glow-experimental.torchjit"
glow_tts = "output.torchjit"
melgan = "melgan_trump_txlearn_2020-05-30_steno_chkpt9800.torchjit"
[[speakers]]
@@ -29,7 +30,8 @@ base_directory = "/home/bt/dev/voder/tacotron_melgan"
[[model_locations]]
model_type = "ArpabetGlowTts" # TODO: This is not the Arpabet I'm using
base_directory = "/home/bt/dev/jit-models/output/glow-tts-jaywalnut"
#base_directory = "/home/bt/dev/jit-models/output/glow-tts-jaywalnut"
base_directory = "/home/bt/dev/jit-models/glow-tts-jaywalnut"
[[model_locations]]
model_type = "Melgan"
@@ -1,5 +1,5 @@
use crate::model::model_container::ModelContainer;
use anyhow::Result;
use anyhow::{Result, Error};
use std::path::Path;
use std::thread;
use std::time::Duration;
@@ -24,6 +24,68 @@ impl ArpabetGlowTtsModel {
let text_tensor = text_tensor.unsqueeze(0);
println!("Text tensor unsq: {:?}", text_tensor);
self.model_container.forward(&text_tensor, )
let lengths_tensor = Tensor::of_slice(&[text_buffer.len() as i64]);
/*
"this is the song that never ends"
x_tst tensor([[ 91, 109, 131, 11, 109, 146, 11, 91, 73, 11, 131, 78, 120, 11,
91, 70, 133, 11, 119, 94, 143, 97, 11, 94, 119, 90, 146]],
device='cuda:0')
x_tst_lengths tensor([27], device='cuda:0')
*/
/*
r: Expected tensor for argument #1 \'indices\' to have scalar type Long;
but got CPUIntType instead (while checking arguments for embedding)\n" }',
tts_service/src/model/model_container.rs:33:5
r: Expected tensor for argument #1 \'indices\' to have scalar type Long;
but got CPUFloatType instead (while checking arguments for embedding)\n" }',
tts_service/src/model/model_container.rs:33:5
*/
/*
tst_stn 39 testing this text to speech generator
sequence 1 [[ 11 133 94 131 133 108 120 11 91 109 131 11 133 94 116 131 133 11
133 141 11 131 129 113 89 11 115 94 119 97 103 133 97 11]]
x_tst 1 tensor([[ 11, 133, 94, 131, 133, 108, 120, 11, 91, 109, 131, 11, 133, 94,
116, 131, 133, 11, 133, 141, 11, 131, 129, 113, 89, 11, 115, 94,
119, 97, 103, 133, 97, 11]])
x_tst_lengths 1 tensor([34])
*/
// let text : Vec<i64> = vec![ 91, 109, 131, 11, 109, 146, 11, 91, 73, 11, 131, 78, 120, 11,
// 91, 70, 133, 11, 119, 94, 143, 97, 11, 94, 119, 90, 146];
let text : Vec<i64> = vec![11, 133, 94, 131, 133, 108, 120, 11, 91, 109, 131,
11, 133, 94, 116, 131, 133, 11, 133, 141, 11, 131, 129, 113, 89, 11, 115, 94,
119, 97, 103, 133, 97, 11];
//let text : Vec<f32> = text.iter().map(|n| *n as i64).collect();
//let one_d : Vec<&[i64]> = vec![text.as_slice()];
//let two_d : &[&[i64]] = one_d.as_slice();
let x_tst = Tensor::of_slice(&text.as_slice());
println!("\n\nTensor size: {:?}", x_tst.size());
let x_tst_2 = x_tst.unsqueeze(0);
println!("\n\nTensor unsqueezed size: {:?}", x_tst_2.size());
//let lengths = [27i64];
let lengths = [34i64];
let x_tst_lengths = Tensor::of_slice(&lengths);
self.model_container.forward2(&x_tst_2, &x_tst_lengths)
}
}
+12
View File
@@ -3,6 +3,8 @@ use tch::CModule;
use tch::Tensor;
use tch::nn::Module;
use std::path::{Path, PathBuf};
use anyhow::Result as AnyhowResult;
use std::fmt::Formatter;
/// Holds the loaded pytorch JIT model
pub struct ModelContainer {
@@ -28,4 +30,14 @@ impl ModelContainer {
pub fn forward(&self, tensor: &Tensor) -> Tensor {
self.jit_model.forward(tensor)
}
pub fn forward2(&self, arg1: &Tensor, arg2: &Tensor) -> Tensor {
let result = self.jit_model.forward_ts(&[arg1, arg2]);
if let Err(err) = result.as_ref() {
println!("error: {:?}", err);
}
result.expect("SHOULD WORK")
}
}