speechbrain.inference.text 模块
指定用于文本处理模块的推理接口。
- 作者
Aku Rouhe 2021
Peter Plantinga 2021
Loren Lugosch 2020
Mirco Ravanelli 2020
Titouan Parcollet 2021
Abdel Heba 2021
Andreas Nautsch 2022, 2023
Pooneh Mousavi 2023
Sylvain de Langen 2023
Adel Moumen 2023
Pradnya Kandarkar 2023
摘要
类
一个即开即用的响应生成模型 |
|
一个预训练的模型实现,用于接受原始自然语言文本作为输入并执行 Grapheme-to-Phoneme (G2P) 转换 |
|
一个即开即用的响应生成模型 |
|
一个即开即用的响应生成模型 |
参考
- 类 speechbrain.inference.text.GraphemeToPhoneme(*args, **kwargs)[source]
基类:
Pretrained
,EncodeDecodePipelineMixin
一个预训练的模型实现,用于接受原始自然语言文本作为输入并执行 Grapheme-to-Phoneme (G2P) 转换
示例
>>> text = ("English is tough. It can be understood " ... "through thorough thought though") >>> from speechbrain.inference.text import GraphemeToPhoneme >>> tmpdir = getfixture('tmpdir') >>> g2p = GraphemeToPhoneme.from_hparams('path/to/model', savedir=tmpdir) >>> phonemes = g2p.g2p(text)
- INPUT_STATIC_KEYS = ['txt']
- OUTPUT_KEYS = ['phonemes']
- property phonemes
返回可用的音素
- property language
返回此模型可用的语言
- class speechbrain.inference.text.ResponseGenerator(*args, **kwargs)[source]
基类:
Pretrained
一个即开即用的响应生成模型
此类可用于根据用户输入生成和继续对话。给定的 YAML 必须包含 *_NEEDED[] 列表中指定的字段。它需要与 custom.py 一起使用,以加载带有添加的标记(如 bos、eos 和说话者标记)的扩展模型。
- MODULES_NEEDED = ['model']
- class speechbrain.inference.text.GPTResponseGenerator(*args, **kwargs)[source]
-
一个即开即用的响应生成模型
此类可用于根据用户输入生成和继续对话。给定的 YAML 必须包含 *_NEEDED[] 列表中指定的字段。它需要与 custom.py 一起使用,以加载带有添加的标记(如 bos、eos 和说话者标记)的扩展 GPT 模型。
示例
>>> from speechbrain.inference.text import GPTResponseGenerator
>>> tmpdir = getfixture("tmpdir") >>> res_gen_model = GPTResponseGenerator.from_hparams(source="speechbrain/MultiWOZ-GPT-Response_Generation", ... pymodule_file="custom.py") >>> response = res_gen_model.generate_response("I want to book a table for dinner")
- class speechbrain.inference.text.Llama2ResponseGenerator(*args, **kwargs)[source]
-
一个即开即用的响应生成模型
此类可用于根据用户输入生成和继续对话。给定的 YAML 必须包含 *_NEEDED[] 列表中指定的字段。它需要与 custom.py 一起使用,以加载带有添加的标记(如 bos、eos 和说话者标记)的扩展 Llama2 模型。
示例
>>> from speechbrain.inference.text import Llama2ResponseGenerator
>>> tmpdir = getfixture("tmpdir") >>> res_gen_model = Llama2ResponseGenerator.from_hparams(source="speechbrain/MultiWOZ-Llama2-Response_Generation", ... pymodule_file="custom.py") >>> response = res_gen_model.generate_response("I want to book a table for dinner")