Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Fix the examples since the API change
Browse files Browse the repository at this point in the history
They got simpler yay!
  • Loading branch information
est31 committed Feb 24, 2020
1 parent d40087d commit 9876695
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 45 deletions.
16 changes: 1 addition & 15 deletions examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ use audrey::read::Reader;
use audrey::sample::interpolate::{Converter, Linear};
use audrey::sample::signal::{from_iter, Signal};

// These constants are taken from the C++ sources of the client.

const BEAM_WIDTH :u16 = 500;

const LM_WEIGHT :f32 = 0.75;
const VALID_WORD_COUNT_WEIGHT :f32 = 1.85;

// The model has been trained on this specific
// sample rate.
const SAMPLE_RATE :u32 = 16_000;
Expand All @@ -36,14 +29,7 @@ fn main() {
let audio_file_path = args().nth(2)
.expect("Please specify an audio file to run STT on");
let dir_path = Path::new(&model_dir_str);
let mut m = Model::load_from_files(
&dir_path.join("output_graph.pb"),
BEAM_WIDTH).unwrap();
m.enable_decoder_with_lm(
&dir_path.join("lm.binary"),
&dir_path.join("trie"),
LM_WEIGHT,
VALID_WORD_COUNT_WEIGHT);
let mut m = Model::load_from_files(&dir_path.join("output_graph.pb")).unwrap();

let initialized_time = Instant::now();
println!("Model initialized in {:?}.", initialized_time - start);
Expand Down
16 changes: 1 addition & 15 deletions examples/client_extended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ use audrey::read::Reader;
use audrey::sample::interpolate::{Converter, Linear};
use audrey::sample::signal::{from_iter, Signal};

// These constants are taken from the C++ sources of the client.

const BEAM_WIDTH :u16 = 500;

const LM_WEIGHT :f32 = 0.75;
const VALID_WORD_COUNT_WEIGHT :f32 = 1.85;

// The model has been trained on this specific
// sample rate.
const SAMPLE_RATE :u32 = 16_000;
Expand All @@ -43,14 +36,7 @@ fn main() {
let audio_file_path = args().nth(2)
.expect("Please specify an audio file to run STT on");
let dir_path = Path::new(&model_dir_str);
let mut m = Model::load_from_files(
&dir_path.join("output_graph.pb"),
BEAM_WIDTH).unwrap();
m.enable_decoder_with_lm(
&dir_path.join("lm.binary"),
&dir_path.join("trie"),
LM_WEIGHT,
VALID_WORD_COUNT_WEIGHT);
let mut m = Model::load_from_files(&dir_path.join("output_graph.pb")).unwrap();

let audio_file = File::open(audio_file_path).unwrap();
let mut reader = Reader::new(audio_file).unwrap();
Expand Down
16 changes: 1 addition & 15 deletions examples/client_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ use audrey::read::Reader;
use audrey::sample::interpolate::{Converter, Linear};
use audrey::sample::signal::{from_iter, Signal};

// These constants are taken from the C++ sources of the client.

const BEAM_WIDTH :u16 = 500;

const LM_WEIGHT :f32 = 0.75;
const VALID_WORD_COUNT_WEIGHT :f32 = 1.85;

// The model has been trained on this specific
// sample rate.
const SAMPLE_RATE :u32 = 16_000;
Expand All @@ -34,14 +27,7 @@ fn main() {
let audio_file_path = args().nth(2)
.expect("Please specify an audio file to run STT on");
let dir_path = Path::new(&model_dir_str);
let mut m = Model::load_from_files(
&dir_path.join("output_graph.pb"),
BEAM_WIDTH).unwrap();
m.enable_decoder_with_lm(
&dir_path.join("lm.binary"),
&dir_path.join("trie"),
LM_WEIGHT,
VALID_WORD_COUNT_WEIGHT);
let mut m = Model::load_from_files(&dir_path.join("output_graph.pb")).unwrap();

let audio_file = File::open(audio_file_path).unwrap();
let mut reader = Reader::new(audio_file).unwrap();
Expand Down

0 comments on commit 9876695

Please sign in to comment.