-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpp.py
32 lines (23 loc) · 1011 Bytes
/
cpp.py
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
from whisper_cpp_python import Whisper
from docx import Document
# Initialize whispercpp in python
model = Whisper(model_path="/home/ajiap/ai/whisper.cpp/models/ggml-large-v3-turbo.bin")
# Path to the audio file
audio_path = "/home/ajiap/ai/ctcfol-syriac22.m4a"
# Transcribe the audio without timestamps
result = model.transcribe(audio_path, language="zh")
# Extract transcription text (without timestamps)
transcription = result["text"]
# Save as plaintext file without timestamps
with open("transcription.txt", "w") as text_file:
text_file.write(transcription)
# Save as markdown file without timestamps
with open("transcription.md", "w") as markdown_file:
markdown_file.write("# Transcription\n\n")
markdown_file.write(transcription)
# Save as docx file without timestamps
doc = Document()
doc.add_heading('Transcription', 0)
doc.add_paragraph(transcription)
doc.save("transcription.docx")
print("Transcription completed and saved as plaintext, markdown, and docx without timestamps.")