Skip to content

Commit

Permalink
Merge pull request #38 from xd009642/feat/make-lib-usable
Browse files Browse the repository at this point in the history
CI?
  • Loading branch information
xd009642 authored Apr 15, 2024
2 parents 50a2715 + 9ad8827 commit e2e2953
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 31 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@ name: Checks

on:
push:
branches: ["main"]
branches:
- "*"
pull_request:
branches: ["main"]

jobs:
build_and_test:
name: Rust project
runs-on: ubuntu-latest
services:
steps:
- uses: actions/checkout@v3
with:
lfs: true
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt clippy
- name: cache
uses: Swatinem/rust-cache@v2
- name: Cargo build
run: cargo build --locked
run: cargo build --locked --no-default-features # I don't want to download an ortruntime so
- name: Cargo test
run: cargo test --locked
run: cargo test --locked --no-default-features
- name: Rustfmt
run: cargo fmt --check
- name: Clippy
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"

[features]
default = ["ort/load-dynamic"]

[dependencies]
anyhow = "1.0.65"
Expand All @@ -22,7 +23,7 @@ ndarray = "0.15.6"
ndarray-npy = "0.8.1" # Just for convenient moving to/from python for checking
num2words = "1.0.1"
once_cell = "1.15.0"
ort = { version = "2.0.0-rc.0", features = ["load-dynamic"] }
ort = { version = "2.0.0-rc.0" }
regex = "1.6.0"
serde = { version = "1.0.192", features = ["derive"] }
serde_json = "1.0.108"
Expand Down
27 changes: 4 additions & 23 deletions src/bin/app.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
use clap::Parser;
use griffin_lim::GriffinLim;
use hound::{SampleFormat, WavSpec, WavWriter};
use std::fs::File;
use std::io::BufWriter;
use std::path::{Path, PathBuf};
use std::time::{Duration, Instant};
use tracing::{debug, error, info};
use xd_tts::phonemes::Unit;
use xd_tts::tacotron2::*;
use xd_tts::text_normaliser::{self, NormaliserChunk};
use hound::WavWriter;
use std::path::PathBuf;
use tracing::info;
use xd_tts::*;

#[derive(Parser, Debug)]
Expand All @@ -30,26 +23,14 @@ pub struct Args {
tacotron2: PathBuf,
}

fn create_wav_writer(output: &Path) -> anyhow::Result<WavWriter<BufWriter<File>>> {
let spec = WavSpec {
channels: 1,
sample_rate: 22050,
bits_per_sample: 16,
sample_format: SampleFormat::Int,
};

let w = WavWriter::create(output, spec)?;
Ok(w)
}

fn main() -> anyhow::Result<()> {
xd_tts::setup_logging();
let args = Args::parse();

info!("Loading resources");

let tts_context = XdTts::new(&args.tacotron2, args.phoneme_input)?;
let mut wav_writer = create_wav_writer(&args.output)?;
let mut wav_writer = WavWriter::create(&args.output, xd_tts::WAV_SPEC)?;

tts_context.generate_audio(&args.input, &mut wav_writer, args.output_spectrogram)?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub mod training;

pub use cmu_dict::CmuDictionary;

pub const wav_spec: WavSpec = WavSpec {
pub const WAV_SPEC: WavSpec = WavSpec {
channels: 1,
sample_rate: 22050,
bits_per_sample: 16,
Expand Down

0 comments on commit e2e2953

Please sign in to comment.