Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望在响应中允许跨域请求 #23

Open
Rainscall opened this issue May 9, 2024 · 2 comments
Open

希望在响应中允许跨域请求 #23

Rainscall opened this issue May 9, 2024 · 2 comments

Comments

@Rainscall
Copy link

Rainscall commented May 9, 2024

使用transformer.js加载模型会向hugging face发送请求,如果用hf-mirror的话,就需要在响应头中包含
Access-Control-Allow-Origin:*

@padeoe
Copy link
Owner

padeoe commented May 11, 2024

问个问题,huggingface.co 支持跨域吗?另外有最小的代码sample和测试方法用于测试是否支持跨域吗,我修改后方便测试

@Rainscall
Copy link
Author

Rainscall commented May 11, 2024

问个问题,huggingface.co 支持跨域吗?另外有最小的代码sample和测试方法用于测试是否支持跨域吗,我修改后方便测试

import { pipeline, env as tFenv } from "https://gcore.jsdelivr.net/npm/@xenova/transformers@2.6.0";
tFenv.remoteHost = 'https://hf-mirror.com';
//此处默认值为https://huggingface.co,是支持跨域的

const transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
const output = await transcriber(url);

console.log(output);
//不出意外的话这里会输出一个带有text的json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants