Haystack docs home page

🎉 We are working to make this website better, stay tuned. In the meantime, have a look at our up to date Pipeline Nodes section in the new docs.


Use this node in question-answering pipelines to convert text Answers into SpeechAnswers. The answer and its context are read out into two audio files.

This node is experimental because of the dataclasses it uses (SpeechAnswer). Bear in mind that that they might change in the future.

Position in a PipelineThe last node in the pipeline, after a Reader


To initialize AnswerToSpeech, run:

from haystack.nodes import AnswerToSpeech
model_name = 'espnet/kan-bayashi_ljspeech_vits'
answer_dir = './generated_audio_answers'
audio_answer = AnswerToSpeech(model_name_or_path=model_name, generated_audio_dir=answer_dir)

To use AnswerToSpeech in a pipeline, run:

from haystack.nodes import AnswerToSpeech
retriever = BM25Retriever(document_store=document_store)
reader = FARMReader(model_name_or_path="deepset/roberta-base-squad2", use_gpu=True)
answer2speech = AnswerToSpeech(
generated_audio_dir=Path(__file__).parent / "audio_answers",
audio_pipeline = Pipeline()
audio_pipeline.add_node(retriever, name="Retriever", inputs=["Query"])
audio_pipeline.add_node(reader, name="Reader", inputs=["Retriever"])
audio_pipeline.add_node(answer2speech, name="AnswerToSpeech", inputs=["Reader"])