Open Rainscall opened 1 month ago
问个问题,huggingface.co 支持跨域吗?另外有最小的代码sample和测试方法用于测试是否支持跨域吗,我修改后方便测试
问个问题,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
使用transformer.js加载模型会向hugging face发送请求,如果用hf-mirror的话,就需要在响应头中包含
Access-Control-Allow-Origin:*