Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load model and tokenizer
5model_name = "cesp99/qwen3-sussurro"
6model = AutoModelForCausalLM.from_pretrained(
7 model_name,
8 device_map="auto",
9 trust_remote_code=True,
10 torch_dtype=torch.bfloat16,
11)
12tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
13
14# System prompt
15system_prompt = """You are a speech-to-text correction specialist. Your task is to convert raw speech transcriptions into clean, written text by:
16- Removing all filler words (um, uh, like, you know, I mean, actually, literally, right, you see)
17- Fixing stuttering and repeated words (the the → the, we we → we)
18- Eliminating false starts and self-corrections
19- Converting conversational speech patterns to formal written language
20- Organizing rambling thoughts into clear, structured sentences
21- Preserving all important meaning and content"""
22
23# Example correction
24raw_speech = "so, uh, I was thinking like maybe we could, you know, meet up on Saturday?"
25
26messages = [
27 {"role": "system", "content": system_prompt},
28 {"role": "user", "content": raw_speech},
29]
30
31prompt = tokenizer.apply_chat_template(
32 messages,
33 tokenize=False,
34 add_generation_prompt=True,
35 enable_thinking=False,
36)
37
38inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
39
40outputs = model.generate(
41 **inputs,
42 max_new_tokens=256,
43 temperature=0.7,
44 top_p=0.8,
45 top_k=20,
46 do_sample=True,
47)
48
49corrected_text = tokenizer.decode(
50 outputs[0][inputs['input_ids'].shape[1]:],
51 skip_special_tokens=True
52)
53
54print(corrected_text)
55# Output: "I was thinking maybe we could meet up on Saturday?"1@misc{qwen3-sussurro,
2 title={Qwen3-1.7B Sussurro},
3 author={Carlo Esposito},
4 year={2026},
5 publisher={Hugging Face},
6 url={https://huggingface.co/cesp99/qwen3-sussurro}
7}