Instructions to use khazarai/Cardiology-TTS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use khazarai/Cardiology-TTS with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/csm-1b") model = PeftModel.from_pretrained(base_model, "khazarai/Cardiology-TTS") - Transformers
How to use khazarai/Cardiology-TTS with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-to-speech", model="khazarai/Cardiology-TTS")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("khazarai/Cardiology-TTS", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download chat_template.jinja from khazarai/Cardiology-TTS: direct link, hf CLI and curl.
- Browser
- Download file 2 kB
-
https://huggingface.co/khazarai/Cardiology-TTS/resolve/830f9c4b2771650f3c01c8bdb3e991108c9f23f4/chat_template.jinja
- Command line
-
hf download hf://khazarai/Cardiology-TTS@830f9c4b2771650f3c01c8bdb3e991108c9f23f4/chat_template.jinja
-
curl -L -o chat_template.jinja https://huggingface.co/khazarai/Cardiology-TTS/resolve/830f9c4b2771650f3c01c8bdb3e991108c9f23f4/chat_template.jinja
2 kB
| {%- for message in messages %} | |
| {#-- Validate role is a stringified integer --#} | |
| {%- if not message['role'] is string or not message['role'].isdigit() %} | |
| {{- raise_exception("The role must be an integer or a stringified integer (e.g. '0') designating the speaker id") }} | |
| {%- endif %} | |
| {#-- Validate content is a list --#} | |
| {%- set content = message['content'] %} | |
| {%- if content is not iterable or content is string %} | |
| {{- raise_exception("The content must be a list") }} | |
| {%- endif %} | |
| {#-- Collect content types --#} | |
| {%- set content_types = content | map(attribute='type') | list %} | |
| {%- set is_last = loop.last %} | |
| {#-- Last message validation --#} | |
| {%- if is_last %} | |
| {%- if 'text' not in content_types %} | |
| {{- raise_exception("The last message must include one item of type 'text'") }} | |
| {%- elif (content_types | select('equalto', 'text') | list | length > 1) or (content_types | select('equalto', 'audio') | list | length > 1) %} | |
| {{- raise_exception("At most two items are allowed in the last message: one 'text' and one 'audio'") }} | |
| {%- endif %} | |
| {#-- All other messages validation --#} | |
| {%- else %} | |
| {%- if content_types | select('equalto', 'text') | list | length != 1 | |
| or content_types | select('equalto', 'audio') | list | length != 1 %} | |
| {{- raise_exception("Each message (except the last) must contain exactly one 'text' and one 'audio' item") }} | |
| {%- elif content_types | reject('in', ['text', 'audio']) | list | length > 0 %} | |
| {{- raise_exception("Only 'text' and 'audio' types are allowed in content") }} | |
| {%- endif %} | |
| {%- endif %} | |
| {%- endfor %} | |
| {%- for message in messages %} | |
| {{- bos_token }} | |
| {{- '[' + message['role'] + ']' }} | |
| {{- message['content'][0]['text'] }} | |
| {{- eos_token }} | |
| {%- if message['content']|length > 1 %} | |
| {{- '<|AUDIO|><|audio_eos|>' }} | |
| {%- endif %} | |
| {%- endfor %} | |