c56bef871b
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
Docker image release / Build base image (push) Has been cancelled
Sync docs with Docusaurus / sync (push) Has been cancelled
Tests / Check if changed (push) Has been cancelled
Tests / format (push) Has been cancelled
Tests / check-imports (push) Has been cancelled
Tests / Unit / macos-latest (push) Has been cancelled
Tests / Unit / ubuntu-latest (push) Has been cancelled
Tests / Unit / windows-latest (push) Has been cancelled
Tests / mypy (push) Has been cancelled
Tests / Integration / ubuntu-latest (push) Has been cancelled
Tests / Integration / macos-latest (push) Has been cancelled
Tests / Integration / windows-latest (push) Has been cancelled
Tests / notify-slack-on-failure (push) Has been cancelled
Tests / Mark tests as completed (push) Has been cancelled
68 lines
2.4 KiB
Plaintext
68 lines
2.4 KiB
Plaintext
---
|
||
title: "FunASRTranscriber"
|
||
id: funasrtranscriber
|
||
slug: "/funasrtranscriber"
|
||
description: "Transcribe audio files to Documents using FunASR — a local, open-source speech recognition toolkit supporting 50+ languages."
|
||
---
|
||
|
||
# FunASRTranscriber
|
||
|
||
Transcribe audio files to Haystack Documents using FunASR — a local, open-source speech recognition toolkit supporting 50+ languages.
|
||
|
||
<div className="key-value-table">
|
||
|
||
| | |
|
||
| --- | --- |
|
||
| **Most common position in a pipeline** | As the first component in an indexing pipeline |
|
||
| **Mandatory run variables** | `sources`: A list of audio file paths (`str` or `Path`) or `ByteStream` objects |
|
||
| **Output variables** | `documents`: A list of Haystack Documents, one per source, with transcript text in `content` |
|
||
| **API reference** | [FunASR integration](/reference/integrations-funasr) |
|
||
| **GitHub link** | https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/funasr/src/haystack_integrations/components/audio/funasr/transcriber.py |
|
||
|
||
</div>
|
||
|
||
## Overview
|
||
|
||
`FunASRTranscriber` uses [FunASR](https://github.com/modelscope/FunASR), an open-source speech recognition toolkit from Alibaba DAMO Academy, to transcribe audio files into Haystack `Document` objects. It runs entirely locally — no API key required.
|
||
|
||
The default model is `iic/SenseVoiceSmall`, a multilingual model supporting 50+ languages that is 5–10x faster than Whisper. Models are downloaded from ModelScope on first use and cached in `~/.cache/modelscope`.
|
||
|
||
The component accepts audio file paths (`str` or `Path`) as well as `ByteStream` objects. Call `warm_up()` before running in a pipeline to load the model into memory.
|
||
|
||
## Usage
|
||
|
||
### On its own
|
||
|
||
```python
|
||
from haystack_integrations.components.audio.funasr import FunASRTranscriber
|
||
|
||
transcriber = FunASRTranscriber()
|
||
transcriber.warm_up()
|
||
|
||
result = transcriber.run(sources=["speech.wav"])
|
||
print(result["documents"][0].content)
|
||
```
|
||
|
||
### In a pipeline
|
||
|
||
```python
|
||
from haystack import Pipeline
|
||
from haystack.components.fetchers import LinkContentFetcher
|
||
from haystack_integrations.components.audio.funasr import FunASRTranscriber
|
||
|
||
pipe = Pipeline()
|
||
pipe.add_component("fetcher", LinkContentFetcher())
|
||
pipe.add_component("transcriber", FunASRTranscriber())
|
||
|
||
pipe.connect("fetcher", "transcriber")
|
||
|
||
result = pipe.run(
|
||
data={
|
||
"fetcher": {
|
||
"urls": ["https://example.com/interview.wav"],
|
||
},
|
||
}
|
||
)
|
||
print(result["transcriber"]["documents"][0].content)
|
||
```
|