diff options
author | Nicolas Patry <patry.nicolas@protonmail.com> | 2023-07-27 20:05:02 +0200 |
---|---|---|
committer | Nicolas Patry <patry.nicolas@protonmail.com> | 2023-07-27 20:05:02 +0200 |
commit | ca479a873eeebb21cdef1e2a95d11fea742390f4 (patch) | |
tree | 9eacde1a20b627cd468c22d10bce70593412a961 /candle-examples/examples/whisper/main.rs | |
parent | f291065f6cac82827a47a736ebf78e4fc9c7c569 (diff) | |
download | candle-ca479a873eeebb21cdef1e2a95d11fea742390f4.tar.gz candle-ca479a873eeebb21cdef1e2a95d11fea742390f4.tar.bz2 candle-ca479a873eeebb21cdef1e2a95d11fea742390f4.zip |
Upgrading hf-hub to `0.2.0` (Modified API to not pass the Repo around
all the time)
Diffstat (limited to 'candle-examples/examples/whisper/main.rs')
-rw-r--r-- | candle-examples/examples/whisper/main.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/candle-examples/examples/whisper/main.rs b/candle-examples/examples/whisper/main.rs index 079424e3..c03779e7 100644 --- a/candle-examples/examples/whisper/main.rs +++ b/candle-examples/examples/whisper/main.rs @@ -282,28 +282,23 @@ fn main() -> Result<()> { std::path::PathBuf::from(args.input.expect("You didn't specify a file to read from yet, are using a local model, please add `--input example.wav` to read some audio file")), ) } else { - let repo = Repo::with_revision(model_id, RepoType::Model, revision); let api = Api::new()?; + let dataset = api.dataset("Narsil/candle-examples".to_string()); + let repo = api.repo(Repo::with_revision(model_id, RepoType::Model, revision)); let sample = if let Some(input) = args.input { if let Some(sample) = input.strip_prefix("sample:") { - api.get( - &Repo::new("Narsil/candle-examples".to_string(), RepoType::Dataset), - &format!("samples_{sample}.wav"), - )? + dataset.get(&format!("samples_{sample}.wav"))? } else { std::path::PathBuf::from(input) } } else { println!("No audio file submitted: Downloading https://huggingface.co/datasets/Narsil/candle_demo/blob/main/samples_jfk.wav"); - api.get( - &Repo::new("Narsil/candle-examples".to_string(), RepoType::Dataset), - "samples_jfk.wav", - )? + dataset.get("samples_jfk.wav")? }; ( - api.get(&repo, "config.json")?, - api.get(&repo, "tokenizer.json")?, - api.get(&repo, "model.safetensors")?, + repo.get("config.json")?, + repo.get("tokenizer.json")?, + repo.get("model.safetensors")?, sample, ) }; |