Text-to-Speech
KimiAudio
Safetensors
English
Chinese
audio
audio-language-model
speech-recognition
audio-understanding
audio-generation
chat
custom_code
Instructions to use moonshotai/Kimi-Audio-7B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KimiAudio
How to use moonshotai/Kimi-Audio-7B-Instruct with KimiAudio:
# Example usage for KimiAudio # pip install git+https://github.com/MoonshotAI/Kimi-Audio.git from kimia_infer.api.kimia import KimiAudio model = KimiAudio(model_path="moonshotai/Kimi-Audio-7B-Instruct", load_detokenizer=True) sampling_params = { "audio_temperature": 0.8, "audio_top_k": 10, "text_temperature": 0.0, "text_top_k": 5, } # For ASR asr_audio = "asr_example.wav" messages_asr = [ {"role": "user", "message_type": "text", "content": "Please transcribe the following audio:"}, {"role": "user", "message_type": "audio", "content": asr_audio} ] _, text = model.generate(messages_asr, **sampling_params, output_type="text") print(text) # For Q&A qa_audio = "qa_example.wav" messages_conv = [{"role": "user", "message_type": "audio", "content": qa_audio}] wav, text = model.generate(messages_conv, **sampling_params, output_type="both") sf.write("output_audio.wav", wav.cpu().view(-1).numpy(), 24000) print(text) - Notebooks
- Google Colab
- Kaggle
Refactor Logits Naming
#15
by codecho - opened
modeling_moonshot_kimia.py
CHANGED
|
@@ -902,15 +902,15 @@ class MoonshotKimiaForCausalLM(Qwen2PreTrainedModel):
|
|
| 902 |
else:
|
| 903 |
hidden_states, mimo_hidden_states = outputs[0], outputs[1]
|
| 904 |
|
| 905 |
-
|
| 906 |
-
|
| 907 |
|
| 908 |
if not return_dict:
|
| 909 |
-
output = (
|
| 910 |
return output
|
| 911 |
return CausalLMOutputWithPast(
|
| 912 |
loss=None,
|
| 913 |
-
logits=(
|
| 914 |
past_key_values=outputs.past_key_values,
|
| 915 |
hidden_states=outputs.hidden_states,
|
| 916 |
attentions=outputs.attentions,
|
|
|
|
| 902 |
else:
|
| 903 |
hidden_states, mimo_hidden_states = outputs[0], outputs[1]
|
| 904 |
|
| 905 |
+
text_logits = self.lm_head(hidden_states)
|
| 906 |
+
audio_logits = self.mimo_output(mimo_hidden_states)
|
| 907 |
|
| 908 |
if not return_dict:
|
| 909 |
+
output = (audio_logits, text_logits) + outputs[2:]
|
| 910 |
return output
|
| 911 |
return CausalLMOutputWithPast(
|
| 912 |
loss=None,
|
| 913 |
+
logits=(audio_logits, text_logits),
|
| 914 |
past_key_values=outputs.past_key_values,
|
| 915 |
hidden_states=outputs.hidden_states,
|
| 916 |
attentions=outputs.attentions,
|