Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 1 addition & 58 deletions docs/inference-providers/tasks/audio-classification.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,64 +38,7 @@ Explore all available models and find the one that suits you best [here](https:/
### Using the API


<inferencesnippet>

<curl>
```bash
curl https://router.huggingface.co/hf-inference/models/speechbrain/google_speech_command_xvector \
-X POST \
--data-binary '@sample1.flac' \
-H 'Authorization: Bearer hf_***'
```
</curl>

<python>
```py
import requests

API_URL = "https://router.huggingface.co/hf-inference/v1"
headers = {"Authorization": "Bearer hf_***"}

def query(filename):
with open(filename, "rb") as f:
data = f.read()
response = requests.post(API_URL, headers=headers, data=data)
return response.json()

output = query("sample1.flac")
```

To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.audio_classification).
</python>

<js>
```js
async function query(filename) {
const data = fs.readFileSync(filename);
const response = await fetch(
"https://router.huggingface.co/hf-inference/models/speechbrain/google_speech_command_xvector",
{
headers: {
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
body: data,
}
);
const result = await response.json();
return result;
}

query("sample1.flac").then((response) => {
console.log(JSON.stringify(response));
});
```

To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#audioclassification).
</js>

</inferencesnippet>
No snippet available for this task.



Expand Down
81 changes: 4 additions & 77 deletions docs/inference-providers/tasks/automatic-speech-recognition.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,83 +37,10 @@ Explore all available models and find the one that suits you best [here](https:/
### Using the API


<inferencesnippet>

<curl>
```bash
curl https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3 \
-X POST \
--data-binary '@sample1.flac' \
-H 'Authorization: Bearer hf_***'
```
</curl>

<python>
```py
import requests

API_URL = "https://router.huggingface.co/hf-inference/v1"
headers = {"Authorization": "Bearer hf_***"}

def query(filename):
with open(filename, "rb") as f:
data = f.read()
response = requests.post(API_URL, headers=headers, data=data)
return response.json()

output = query("sample1.flac")
```

To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.automatic_speech_recognition).
</python>

<js>
Using `huggingface.js`:
```js
import { HfInference } from "@huggingface/inference";

const client = new HfInference("hf_***");

const data = fs.readFileSync("sample1.flac");

const output = await client.automaticSpeechRecognition({
data,
model: "openai/whisper-large-v3",
provider: "hf-inference",
});

console.log(output);

```

Using `fetch`:
```js
async function query(filename) {
const data = fs.readFileSync(filename);
const response = await fetch(
"https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3",
{
headers: {
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
body: data,
}
);
const result = await response.json();
return result;
}

query("sample1.flac").then((response) => {
console.log(JSON.stringify(response));
});
```

To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#automaticspeechrecognition).
</js>

</inferencesnippet>
<InferenceSnippet
pipeline=automatic-speech-recognition
providersMapping={ {"fal-ai":{"modelId":"openai/whisper-large-v3","providerModelId":"fal-ai/whisper"},"hf-inference":{"modelId":"openai/whisper-large-v3-turbo","providerModelId":"openai/whisper-large-v3-turbo"}} }
/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in the end you don't embed the full snippets in the markdown. Correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we still need to regenerate the .md from time to time to pick up the mapping?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly. If we want we can still have an .md export for llms but not for now

Copy link
Collaborator

@mishig25 mishig25 Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we still need to regenerate the .md from time to time to pick up the mapping?

yep, written here

image

Copy link
Collaborator

@mishig25 mishig25 Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in the end you don't embed the full snippets in the markdown. Correct?

inference snippets strings are directly coming from https://github.com/huggingface/huggingface.js (single source of truth)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ I think that statement does not hold anymore - we moved snippets code to moon-landing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a confusion here 😬

Inference snippets are indeed located in huggingface.js/inference (or I'm not aware of the change) and providers mapping is on the Hub => and pulled from the Hub by the script in this PR to make sure we always get up-to-date models in the docs => done in CI once a day

So all good, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I've mistaken 'snippets' and 'widgets' - my bad!




Expand Down
Loading