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

Commit 9876695

Browse files
committed
Fix the examples since the API change
They got simpler yay!
1 parent d40087d commit 9876695

File tree

3 files changed

+3
-45
lines changed

3 files changed

+3
-45
lines changed

examples/client.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ use audrey::read::Reader;
1111
use audrey::sample::interpolate::{Converter, Linear};
1212
use audrey::sample::signal::{from_iter, Signal};
1313

14-
// These constants are taken from the C++ sources of the client.
15-
16-
const BEAM_WIDTH :u16 = 500;
17-
18-
const LM_WEIGHT :f32 = 0.75;
19-
const VALID_WORD_COUNT_WEIGHT :f32 = 1.85;
20-
2114
// The model has been trained on this specific
2215
// sample rate.
2316
const SAMPLE_RATE :u32 = 16_000;
@@ -36,14 +29,7 @@ fn main() {
3629
let audio_file_path = args().nth(2)
3730
.expect("Please specify an audio file to run STT on");
3831
let dir_path = Path::new(&model_dir_str);
39-
let mut m = Model::load_from_files(
40-
&dir_path.join("output_graph.pb"),
41-
BEAM_WIDTH).unwrap();
42-
m.enable_decoder_with_lm(
43-
&dir_path.join("lm.binary"),
44-
&dir_path.join("trie"),
45-
LM_WEIGHT,
46-
VALID_WORD_COUNT_WEIGHT);
32+
let mut m = Model::load_from_files(&dir_path.join("output_graph.pb")).unwrap();
4733

4834
let initialized_time = Instant::now();
4935
println!("Model initialized in {:?}.", initialized_time - start);

examples/client_extended.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ use audrey::read::Reader;
1111
use audrey::sample::interpolate::{Converter, Linear};
1212
use audrey::sample::signal::{from_iter, Signal};
1313

14-
// These constants are taken from the C++ sources of the client.
15-
16-
const BEAM_WIDTH :u16 = 500;
17-
18-
const LM_WEIGHT :f32 = 0.75;
19-
const VALID_WORD_COUNT_WEIGHT :f32 = 1.85;
20-
2114
// The model has been trained on this specific
2215
// sample rate.
2316
const SAMPLE_RATE :u32 = 16_000;
@@ -43,14 +36,7 @@ fn main() {
4336
let audio_file_path = args().nth(2)
4437
.expect("Please specify an audio file to run STT on");
4538
let dir_path = Path::new(&model_dir_str);
46-
let mut m = Model::load_from_files(
47-
&dir_path.join("output_graph.pb"),
48-
BEAM_WIDTH).unwrap();
49-
m.enable_decoder_with_lm(
50-
&dir_path.join("lm.binary"),
51-
&dir_path.join("trie"),
52-
LM_WEIGHT,
53-
VALID_WORD_COUNT_WEIGHT);
39+
let mut m = Model::load_from_files(&dir_path.join("output_graph.pb")).unwrap();
5440

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

examples/client_simple.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ use audrey::read::Reader;
1010
use audrey::sample::interpolate::{Converter, Linear};
1111
use audrey::sample::signal::{from_iter, Signal};
1212

13-
// These constants are taken from the C++ sources of the client.
14-
15-
const BEAM_WIDTH :u16 = 500;
16-
17-
const LM_WEIGHT :f32 = 0.75;
18-
const VALID_WORD_COUNT_WEIGHT :f32 = 1.85;
19-
2013
// The model has been trained on this specific
2114
// sample rate.
2215
const SAMPLE_RATE :u32 = 16_000;
@@ -34,14 +27,7 @@ fn main() {
3427
let audio_file_path = args().nth(2)
3528
.expect("Please specify an audio file to run STT on");
3629
let dir_path = Path::new(&model_dir_str);
37-
let mut m = Model::load_from_files(
38-
&dir_path.join("output_graph.pb"),
39-
BEAM_WIDTH).unwrap();
40-
m.enable_decoder_with_lm(
41-
&dir_path.join("lm.binary"),
42-
&dir_path.join("trie"),
43-
LM_WEIGHT,
44-
VALID_WORD_COUNT_WEIGHT);
30+
let mut m = Model::load_from_files(&dir_path.join("output_graph.pb")).unwrap();
4531

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

0 commit comments

Comments
 (0)