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
File size: 3,047 Bytes
0ff4877 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | {{- 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 %} |