Skip to content

Commit 8331942

Browse files
committed
better now? :)
1 parent d539697 commit 8331942

23 files changed

+1662
-637
lines changed

docs/api-inference/tasks/audio-classification.md

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -29,92 +29,13 @@ For more details about the `audio-classification` task, check out its [dedicated
2929

3030
### Recommended models
3131

32-
- [speechbrain/google_speech_command_xvector](https://huggingface.co/speechbrain/google_speech_command_xvector): An easy-to-use model for command recognition.
33-
- [ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition](https://huggingface.co/ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition): An emotion recognition model.
34-
- [facebook/mms-lid-126](https://huggingface.co/facebook/mms-lid-126): A language identification model.
3532

3633
Explore all available models and find the one that suits you best [here](https://huggingface.co/models?inference=warm&pipeline_tag=audio-classification&sort=trending).
3734

3835
### Using the API
3936

4037

41-
<inferencesnippet>
42-
43-
<snippet provider="hf-inference" language="python" client="huggingface_hub">
44-
45-
```python
46-
from huggingface_hub import InferenceClient
47-
48-
client = InferenceClient(
49-
provider="hf-inference",
50-
api_key="hf_***",
51-
)
52-
53-
output = client.audio_classification("sample1.flac", model="speechbrain/google_speech_command_xvector")
54-
```
55-
56-
</snippet>
57-
58-
To use the Python `InferenceClient`, see the [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.).
59-
<snippet provider="hf-inference" language="python" client="requests">
60-
61-
```python
62-
import requests
63-
64-
API_URL = "https://router.huggingface.co/hf-inference/models/speechbrain/google_speech_command_xvector"
65-
headers = {"Authorization": "Bearer hf_***"}
66-
67-
def query(filename):
68-
with open(filename, "rb") as f:
69-
data = f.read()
70-
response = requests.post(API_URL, headers={"Content-Type": "audio/flac", **headers}, data=data)
71-
return response.json()
72-
73-
output = query("sample1.flac")
74-
```
75-
76-
</snippet>
77-
78-
<snippet provider="hf-inference" language="js" client="fetch">
79-
80-
```js
81-
async function query(data) {
82-
const response = await fetch(
83-
"https://router.huggingface.co/hf-inference/models/speechbrain/google_speech_command_xvector",
84-
{
85-
headers: {
86-
Authorization: "Bearer hf_***",
87-
"Content-Type": "audio/flac"
88-
},
89-
method: "POST",
90-
body: JSON.stringify(data),
91-
}
92-
);
93-
const result = await response.json();
94-
return result;
95-
}
96-
97-
query({ inputs: "sample1.flac" }).then((response) => {
98-
console.log(JSON.stringify(response));
99-
});
100-
```
101-
102-
</snippet>
103-
104-
<snippet provider="hf-inference" language="sh" client="curl">
105-
106-
```sh
107-
curl https://router.huggingface.co/hf-inference/models/speechbrain/google_speech_command_xvector \
108-
-X POST \
109-
-H 'Authorization: Bearer hf_***' \
110-
-H 'Content-Type: audio/flac' \
111-
--data-binary @"sample1.flac"
112-
```
113-
114-
</snippet>
115-
116-
117-
</inferencesnippet>
38+
No snippet available for this task.
11839

11940

12041

docs/api-inference/tasks/automatic-speech-recognition.md

Lines changed: 114 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ For more details about the `automatic-speech-recognition` task, check out its [d
2929

3030
### Recommended models
3131

32-
- [openai/whisper-large-v3](https://huggingface.co/openai/whisper-large-v3): A powerful ASR model by OpenAI.
33-
- [facebook/seamless-m4t-v2-large](https://huggingface.co/facebook/seamless-m4t-v2-large): An end-to-end model that performs ASR and Speech Translation by MetaAI.
3432

3533
Explore all available models and find the one that suits you best [here](https://huggingface.co/models?inference=warm&pipeline_tag=automatic-speech-recognition&sort=trending).
3634

@@ -39,8 +37,108 @@ Explore all available models and find the one that suits you best [here](https:/
3937

4038
<inferencesnippet>
4139

40+
41+
<snippet provider="fal-ai" language="python" client="huggingface_hub">
42+
43+
```python
44+
from huggingface_hub import InferenceClient
45+
46+
client = InferenceClient(
47+
provider="fal-ai",
48+
api_key="hf_***",
49+
)
50+
51+
output = client.automatic_speech_recognition("sample1.flac", model="openai/whisper-large-v3")
52+
```
53+
54+
</snippet>
55+
56+
To use the Python `InferenceClient`, see the [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.).
57+
58+
<snippet provider="fal-ai" language="python" client="requests">
59+
60+
```python
61+
import requests
62+
63+
API_URL = "https://router.huggingface.co/fal-ai/fal-ai/whisper"
64+
headers = {"Authorization": "Bearer hf_***"}
65+
66+
def query(filename):
67+
with open(filename, "rb") as f:
68+
data = f.read()
69+
response = requests.post(API_URL, headers={"Content-Type": "audio/flac", **headers}, data=data)
70+
return response.json()
71+
72+
output = query("sample1.flac")
73+
```
74+
75+
</snippet>
76+
77+
78+
<snippet provider="fal-ai" language="js" client="fetch">
79+
80+
```js
81+
async function query(data) {
82+
const response = await fetch(
83+
"https://router.huggingface.co/fal-ai/fal-ai/whisper",
84+
{
85+
headers: {
86+
Authorization: "Bearer hf_***",
87+
"Content-Type": "audio/flac"
88+
},
89+
method: "POST",
90+
body: JSON.stringify(data),
91+
}
92+
);
93+
const result = await response.json();
94+
return result;
95+
}
96+
97+
query({ inputs: "sample1.flac" }).then((response) => {
98+
console.log(JSON.stringify(response));
99+
});
100+
```
101+
102+
</snippet>
103+
104+
105+
<snippet provider="fal-ai" language="js" client="huggingface.js">
106+
107+
```js
108+
import { InferenceClient } from "@huggingface/inference";
109+
110+
const client = new InferenceClient("hf_***");
111+
112+
const data = fs.readFileSync("sample1.flac");
113+
114+
const output = await client.automaticSpeechRecognition({
115+
data,
116+
model: "openai/whisper-large-v3",
117+
provider: "fal-ai",
118+
});
119+
120+
console.log(output);
121+
```
122+
123+
</snippet>
124+
125+
To use the JavaScript `InferenceClient`, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/InferenceClient#).
126+
127+
<snippet provider="fal-ai" language="sh" client="curl">
128+
129+
```sh
130+
curl https://router.huggingface.co/fal-ai/fal-ai/whisper \
131+
-X POST \
132+
-H 'Authorization: Bearer hf_***' \
133+
-H 'Content-Type: audio/flac' \
134+
--data-binary @"sample1.flac"
135+
```
136+
137+
</snippet>
138+
139+
42140
<snippet provider="hf-inference" language="python" client="huggingface_hub">
43-
141+
44142
```python
45143
from huggingface_hub import InferenceClient
46144

@@ -49,18 +147,19 @@ client = InferenceClient(
49147
api_key="hf_***",
50148
)
51149

52-
output = client.automatic_speech_recognition("sample1.flac", model="openai/whisper-large-v3")
150+
output = client.automatic_speech_recognition("sample1.flac", model="openai/whisper-large-v3-turbo")
53151
```
54152

55153
</snippet>
56154

57155
To use the Python `InferenceClient`, see the [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.).
156+
58157
<snippet provider="hf-inference" language="python" client="requests">
59-
158+
60159
```python
61160
import requests
62161

63-
API_URL = "https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3"
162+
API_URL = "https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3-turbo"
64163
headers = {"Authorization": "Bearer hf_***"}
65164

66165
def query(filename):
@@ -74,12 +173,13 @@ output = query("sample1.flac")
74173

75174
</snippet>
76175

176+
77177
<snippet provider="hf-inference" language="js" client="fetch">
78-
178+
79179
```js
80180
async function query(data) {
81181
const response = await fetch(
82-
"https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3",
182+
"https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3-turbo",
83183
{
84184
headers: {
85185
Authorization: "Bearer hf_***",
@@ -100,8 +200,9 @@ query({ inputs: "sample1.flac" }).then((response) => {
100200

101201
</snippet>
102202

203+
103204
<snippet provider="hf-inference" language="js" client="huggingface.js">
104-
205+
105206
```js
106207
import { InferenceClient } from "@huggingface/inference";
107208

@@ -111,7 +212,7 @@ const data = fs.readFileSync("sample1.flac");
111212

112213
const output = await client.automaticSpeechRecognition({
113214
data,
114-
model: "openai/whisper-large-v3",
215+
model: "openai/whisper-large-v3-turbo",
115216
provider: "hf-inference",
116217
});
117218

@@ -121,10 +222,11 @@ console.log(output);
121222
</snippet>
122223

123224
To use the JavaScript `InferenceClient`, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/InferenceClient#).
225+
124226
<snippet provider="hf-inference" language="sh" client="curl">
125-
227+
126228
```sh
127-
curl https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3 \
229+
curl https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3-turbo \
128230
-X POST \
129231
-H 'Authorization: Bearer hf_***' \
130232
-H 'Content-Type: audio/flac' \

0 commit comments

Comments
 (0)