Views
No views yet
1from orpheus_tts import OrpheusModel
2import wave
3import time
4
5gpu_memory_utilization = 0.5 ## Change according to how much vram you have, 0.5 is a decent spot
6
7
8model = OrpheusModel(model_name ="YaTharThShaRma999/orpheus_model-4bit-bnb", max_seq_len_to_capture=4096, quantization="bitsandbytes", gpu_memory_utilization=gpu_memory_utilization)
9prompt = '''So um Orpheus seems pretty interesting, doesn't it? Cool right?'''
10
11start_time = time.monotonic()
12syn_tokens = model.generate_speech(
13 prompt=prompt,
14 voice="tara",
15 )
16
17with wave.open("output.wav", "wb") as wf:
18 wf.setnchannels(1)
19 wf.setsampwidth(2)
20 wf.setframerate(24000)
21
22 total_frames = 0
23 chunk_counter = 0
24 for audio_chunk in syn_tokens: # output streaming
25 chunk_counter += 1
26 frame_count = len(audio_chunk) // (wf.getsampwidth() * wf.getnchannels())
27 total_frames += frame_count
28 wf.writeframes(audio_chunk)
29 duration = total_frames / wf.getframerate()
30
31 end_time = time.monotonic()
32 print(f"It took {end_time - start_time} seconds to generate {duration:.2f} seconds of audio")