ds_transcriber/
lib.rs

1#![warn(missing_debug_implementations)]
2#![warn(rustdoc::missing_doc_code_examples)]
3#![warn(rustdoc::broken_intra_doc_links)]
4#![warn(missing_docs)]
5
6//! ds-transcriber
7//! # A deepspeech powered utility for transcribing a microphone stream
8//!
9//! # Prelude
10//!
11//! You can think of this crate as a wrapper for RustAudio's
12//! [deepspeech-rs](https://github.com/rustaudio/deepspeech-rs). It aims to provide transcription
13//! for microphone audio with optional denoising.
14//!
15//!
16//! #### Getting Started
17//!
18//! This example shows the quickest way to get started with ds-transcriber.
19//! First, add ds-transcriber to your `Cargo.toml`
20//!
21//! ```toml
22//! ds-transcriber = "1"
23//! ```
24//!
25//! Download the DeepSpeech [native client](https://github.com/mozilla/DeepSpeech/releases/tag/v0.9.0) and then add its directory to your `LD_LIBRARY_PATH` and
26//! `LIBRARY_PATH` variables.
27//!
28//! Have a look at [StreamSettings](StreamSettings) to fine tune the transcription stream to parameters that better suite
29//! your environment
30//!
31//! ```no_run
32//! # use std::{path::PathBuf, str::FromStr};
33//! # fn main()->Result<(),Box<dyn std::error::Error>>{
34//! let mut model = ds_transcriber::model::instance_model(
35//!     "model_file.pbmm",
36//!     Some("scorer_file.scorer"),
37//! )?;
38//! let config = ds_transcriber::StreamSettings::default();
39//! let i_said = ds_transcriber::transcribe(config, &mut model)?;
40//! println!("I said: {}", i_said);
41//! # Ok(())
42//! # }
43//! ```
44//!
45//! Rinse and repeat the last two lines
46//!
47//! # Features
48//
49//! This crate provides an optional feature of denoising of the audio stream (may result in better
50//! transcription). It is disabled by default, to enable it: use either the `denoise` or `full` key
51//! in the crate's features list
52//!
53//! ```toml
54//! ds-transcriber = { version = "1", features = ["denoise"] } # or features = ["full"]
55//! ```
56//!
57//! # Crate example
58//! Clone the repository and run the example
59//!
60//! For help with arguments, run:
61//! ```sh
62//! cargo run --example transcribe -- -h
63//! ```
64//!
65//! To start the example, run
66//! ```sh
67//! cargo run --example transcribe -- -m model_file -s scorer_file -c deepspeech_native_client_dir
68//! ```
69//! The `s` or `--scorer` argument is optional, but it is recommended to set one.
70//!
71//! # Re-exports
72//!
73//! This crate also re-exports the `deepspeech` and `nnnoiseless` crates (if the `denoise` feature is enabled). You can use these re-exports instead of also depending on them separately.
74//!
75mod config;
76pub mod model;
77mod stream;
78/// Transcription workers
79pub use transcriber::{transcribe, StreamSettings};
80mod transcriber;
81
82/// # Re-exports
83pub use deepspeech;
84#[cfg(feature = "denoise")]
85pub use nnnoiseless;