Instructions to use bosonai/higgs-tts-2-3b-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bosonai/higgs-tts-2-3b-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-to-speech", model="bosonai/higgs-tts-2-3b-base")# Load model directly from transformers import AutoProcessor, AutoModelForTextToWaveform processor = AutoProcessor.from_pretrained("bosonai/higgs-tts-2-3b-base") model = AutoModelForTextToWaveform.from_pretrained("bosonai/higgs-tts-2-3b-base") - Notebooks
- Google Colab
- Kaggle
| {{- bos_token }} | |
| {#- This block extracts the system message, so we can slot it into the right place. #} | |
| {%- if messages[0]['role'] == 'system' %} | |
| {%- if messages[0]['content'] is string %} | |
| {%- set system_message = messages[0]['content']|trim %} | |
| {%- elif messages[0]['content'] is iterable and messages[0]['content'][0]['type'] == 'text' %} | |
| {%- set system_message = messages[0]['content'][0]['text']|trim %} | |
| {%- else %} | |
| {{- raise_exception("System message content must be a string or contain text type!") }} | |
| {%- endif %} | |
| {%- set messages = messages[1:] %} | |
| {%- else %} | |
| {{- raise_exception("A system message is required but not provided!") }} | |
| {%- endif %} | |
| {#- System message #} | |
| {{- "<|start_header_id|>system<|end_header_id|>\n\n" }} | |
| {{- system_message }} | |
| {#- Check for scene message and handle it specially #} | |
| {%- if messages and messages[0]['role'] == 'scene' %} | |
| {{- "\n\n<|scene_desc_start|>\n" }} | |
| {%- if messages[0]['content'] is string %} | |
| {{- messages[0]['content'] | trim }} | |
| {%- elif messages[0]['content'] is iterable %} | |
| {%- for content_item in messages[0]['content'] %} | |
| {%- if content_item['type'] == 'text' %} | |
| {%- set text_content = content_item['text'] | trim %} | |
| {{- text_content }} | |
| {%- if loop.first and not loop.last %} | |
| {{- "\n\n" }} | |
| {%- endif %} | |
| {%- if not loop.first and not loop.last and messages[0]['content'][loop.index]['type'] != 'audio' %} | |
| {{- "\n" }} | |
| {%- endif %} | |
| {%- elif content_item['type'] == 'audio' %} | |
| {{- ' <|audio_out_bos|><|AUDIO_OUT|><|audio_eos|>' }} | |
| {%- if not loop.last %} | |
| {{- "\n" }} | |
| {%- endif %} | |
| {%- endif %} | |
| {%- endfor %} | |
| {%- endif %} | |
| {{- "\n<|scene_desc_end|>" }} | |
| {%- set messages = messages[1:] %} | |
| {%- endif %} | |
| {{- "<|eot_id|>" }} | |
| {#- Loop through all messages #} | |
| {%- for message in messages %} | |
| {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' }} | |
| {%- if message['role'] == 'assistant' %} | |
| {%- if message['content'] is not iterable or message['content'][0]['type'] != 'audio' %} | |
| {{- raise_exception("Assistant messages must contain audio content only!") }} | |
| {%- endif %} | |
| {{- '<|audio_out_bos|><|AUDIO_OUT|><|audio_eos|>' }} | |
| {%- else %} | |
| {%- if message['content'] is string %} | |
| {{- message['content'] | trim }} | |
| {%- elif message['content'] is iterable %} | |
| {%- for content_item in message['content'] %} | |
| {%- if content_item['type'] == 'text' %} | |
| {{- content_item['text'] | trim }} | |
| {%- endif %} | |
| {%- endfor %} | |
| {%- endif %} | |
| {%- endif %} | |
| {{- '<|eot_id|>' }} | |
| {%- endfor %} | |
| {%- if add_generation_prompt %} | |
| {{- '<|start_header_id|>assistant<|end_header_id|>\n\n<|audio_out_bos|>' }} | |
| {%- endif %} |