Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavs10 committed Oct 16, 2023
1 parent d3fb38d commit eed2c54
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions js/src/lib/inferenceSnippets/serveJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ query({"inputs": ${getModelInputSnippet(model)}}).then((response) => {
// Use image
});`;

export const snippetTextToAudio = (model: ModelData, accessToken: string): string =>
`async function query(data) {
const response = await fetch(
"https://api-inference.huggingface.co/models/${model.id}",
{
headers: { Authorization: "Bearer ${accessToken || `{API_TOKEN}`}" },
method: "POST",
body: JSON.stringify(data),
}
);
const result = await response.blob();
return result;
}
query({"inputs": ${getModelInputSnippet(model)}}).then((response) => {
// Use Audio
});`;

export const snippetFile = (model: ModelData, accessToken: string): string =>
`async function query(filename) {
const data = fs.readFileSync(filename);
Expand Down

0 comments on commit eed2c54

Please sign in to comment.