Skip to content

Commit 2eaf0b3

Browse files
authored
Merge pull request #499 from korpling/fix/whisper-include-dictionary
Fix/whisper include dictionary
2 parents f32fddc + c3fbad7 commit 2eaf0b3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Add `diff`, a graph op that highlights editions between subgraphs with specific edge and node annotations
1414
- Add `edit` for directly manipulating the graph via graph updates
1515
- import `whisper`: More format flexibility (json keys can be skipped or have different names)
16+
- import `whisper`: include vocabulary in binary
1617

1718
### Changed
1819

src/importer/whisper.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,11 @@ fn load_json(path: &Path) -> Result<WhisperJSON, anyhow::Error> {
355355
serde_json::from_str(&data).map_err(|e| anyhow!("Could not parse json file: {:?}", e))
356356
}
357357

358-
const VOCAB_FILE_PATH: &str = "src/importer/whisper/vocab.json";
358+
const VOCAB_DATA: &[u8] = include_bytes!("whisper/vocab.json");
359359

360360
fn load_vocabulary() -> Result<BTreeMap<usize, String>, anyhow::Error> {
361-
let data = fs::read_to_string(Path::new(VOCAB_FILE_PATH))?;
362-
serde_json::from_str(&data).map_err(|e| anyhow!("Could not read vocabulary file: {:?}", e))
361+
serde_json::from_slice(VOCAB_DATA)
362+
.map_err(|e| anyhow!("Could not read vocabulary file: {:?}", e))
363363
}
364364

365365
#[cfg(test)]

0 commit comments

Comments
 (0)