danielrosehill commited on
Commit
9a8a0bf
·
1 Parent(s): b260a01
Files changed (5) hide show
  1. README.md +80 -6
  2. app.py +226 -0
  3. icon.jpg +3 -0
  4. requirements.txt +2 -0
  5. system-prompt.md +29 -0
README.md CHANGED
@@ -1,13 +1,87 @@
1
  ---
2
  title: Basic STT Transcript Cleanup
3
- emoji: 👀
4
- colorFrom: red
5
- colorTo: red
6
  sdk: gradio
7
- sdk_version: 5.47.2
8
  app_file: app.py
9
  pinned: false
10
- short_description: Basic text transformation utility for cleaning up STT output
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: Basic STT Transcript Cleanup
3
+ emoji: 🎤
4
+ colorFrom: blue
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: 4.44.0
8
  app_file: app.py
9
  pinned: false
10
+ short_description: Clean up speech-to-text transcripts with AI-powered text processing
11
  ---
12
 
13
+ # Basic STT Transcript Cleanup Tool (Version 3)
14
+
15
+ A foundational speech-to-text transcript remediation tool that provides purpose-agnostic text cleanup instructions. This is the **daily workhorse** for cleaning up raw speech-to-text transcripts that naturally contain undesirable material.
16
+
17
+ ## Purpose & Philosophy
18
+
19
+ This tool implements **Version 3** of the Basic Speech-to-Text Cleanup prompt - a carefully crafted system prompt that provides sufficiently deterministic guidance without overstepping into actual content editing. The challenge in developing this prompt was ensuring it cleans up technical artifacts of speech-to-text conversion while preserving the authentic voice and intent of the original speaker.
20
+
21
+ ## Foundational Design
22
+
23
+ This basic cleanup prompt serves as a **foundation layer** that can be combined with specialized text transformation prompts:
24
+
25
+ - **Standalone Use**: Perfect for general transcript cleanup
26
+ - **Modular Design**: Can be concatenated with purpose-specific prompts from extensive libraries
27
+ - **Purpose-Agnostic**: Works across all content types and domains
28
+ - **Extensible**: Hundreds of specialized transformation prompts can be layered on top
29
+
30
+ ## Features
31
+
32
+ - **AI-Powered Cleanup**: Uses OpenAI's GPT models with a refined system prompt
33
+ - **BYOK (Bring Your Own Key)**: Secure - uses your own OpenAI API key
34
+ - **Copy to Clipboard**: Easy copying of cleaned text
35
+ - **Re-run Capability**: Quickly re-process the same text
36
+ - **System Prompt Viewer**: Transparent - see exactly how the AI processes your text
37
+ - **Deterministic Processing**: Consistent, predictable cleanup results
38
+
39
+ ## How to Use
40
+
41
+ 1. **Enter API Key**: Provide your OpenAI API key (required for processing)
42
+ 2. **Paste Transcript**: Add your raw speech-to-text transcript
43
+ 3. **Process**: Click "Clean Up Transcript" to apply remediation
44
+ 4. **Copy Results**: Use the cleaned output or re-run if needed
45
+
46
+ ## What It Does
47
+
48
+ The tool applies these **foundational improvements** to your transcripts:
49
+
50
+ ### Core Remediations
51
+ - **Removes filler words** ("um", "uh", "like", etc.)
52
+ - **Adds proper punctuation** and sentence structure
53
+ - **Fixes obvious transcription errors** and hallucinations
54
+ - **Removes repetitive phrases** and run-on thoughts
55
+ - **Improves paragraph spacing** for readability
56
+ - **Follows inferred instructions** (e.g., "scratch that from the note")
57
+
58
+ ### What It Preserves
59
+ - **All important content** and meaning
60
+ - **Original speaker's voice** and intent
61
+ - **Factual accuracy** and details
62
+ - **Natural flow** of conversation
63
+
64
+ ## Design Principles
65
+
66
+ 1. **Light Touch Editing**: Minimal intervention while maximizing clarity
67
+ 2. **Content Preservation**: Never removes or alters important information
68
+ 3. **Deterministic Guidance**: Consistent, predictable results
69
+ 4. **Purpose Agnostic**: Works across all content domains
70
+ 5. **Modular Foundation**: Ready for specialized prompt layering
71
+
72
+ ## Extended Ecosystem
73
+
74
+ This basic cleanup prompt is part of a larger ecosystem:
75
+ - **Hundreds of specialized prompts** available in shared libraries
76
+ - **Domain-specific transformations** for various use cases
77
+ - **Concatenation-ready design** for complex workflows
78
+ - **Shared on Hugging Face** and other platforms
79
+
80
+ ## System Prompt
81
+
82
+ The tool uses a carefully crafted system prompt (Version 3, September 2025) that balances cleanup effectiveness with content preservation. View the complete prompt using the "Show System Prompt" feature in the interface.
83
+
84
+ ## Created By
85
+
86
+ **[Daniel Rosehill](https://danielrosehill.com)** - Specializing in AI-powered text processing and speech-to-text optimization workflows.
87
+
app.py ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from openai import OpenAI
4
+ # Load system prompt and README
5
+ def load_system_prompt():
6
+ with open("system-prompt.md", "r") as f:
7
+ return f.read()
8
+
9
+ SYSTEM_PROMPT_CONTENT = load_system_prompt()
10
+
11
+ # README content for About tab
12
+ README_CONTENT = """# Basic STT Transcript Cleanup Tool (Version 3)
13
+
14
+ A foundational speech-to-text transcript remediation tool that provides purpose-agnostic text cleanup instructions. This is the **daily workhorse** for cleaning up raw speech-to-text transcripts that naturally contain undesirable material.
15
+
16
+ ## Purpose & Philosophy
17
+
18
+ This tool implements **Version 3** of the Basic Speech-to-Text Cleanup prompt - a carefully crafted system prompt that provides sufficiently deterministic guidance without overstepping into actual content editing. The challenge in developing this prompt was ensuring it cleans up technical artifacts of speech-to-text conversion while preserving the authentic voice and intent of the original speaker.
19
+
20
+ ## Foundational Design
21
+
22
+ This basic cleanup prompt serves as a **foundation layer** that can be combined with specialized text transformation prompts:
23
+
24
+ - **Standalone Use**: Perfect for general transcript cleanup
25
+ - **Modular Design**: Can be concatenated with purpose-specific prompts from extensive libraries
26
+ - **Purpose-Agnostic**: Works across all content types and domains
27
+ - **Extensible**: Hundreds of specialized transformation prompts can be layered on top
28
+
29
+ ## Features
30
+
31
+ - **AI-Powered Cleanup**: Uses OpenAI's GPT models with a refined system prompt
32
+ - **BYOK (Bring Your Own Key)**: Secure - uses your own OpenAI API key
33
+ - **Copy to Clipboard**: Easy copying of cleaned text
34
+ - **Re-run Capability**: Quickly re-process the same text
35
+ - **System Prompt Viewer**: Transparent - see exactly how the AI processes your text
36
+ - **Deterministic Processing**: Consistent, predictable cleanup results
37
+
38
+ ## How to Use
39
+
40
+ 1. **Enter API Key**: Provide your OpenAI API key (required for processing)
41
+ 2. **Paste Transcript**: Add your raw speech-to-text transcript
42
+ 3. **Process**: Click "Clean Up Transcript" to apply remediation
43
+ 4. **Copy Results**: Use the cleaned output or re-run if needed
44
+
45
+ ## What It Does
46
+
47
+ The tool applies these **foundational improvements** to your transcripts:
48
+
49
+ ### Core Remediations
50
+ - **Removes filler words** ("um", "uh", "like", etc.)
51
+ - **Adds proper punctuation** and sentence structure
52
+ - **Fixes obvious transcription errors** and hallucinations
53
+ - **Removes repetitive phrases** and run-on thoughts
54
+ - **Improves paragraph spacing** for readability
55
+ - **Follows inferred instructions** (e.g., "scratch that from the note")
56
+
57
+ ### What It Preserves
58
+ - **All important content** and meaning
59
+ - **Original speaker's voice** and intent
60
+ - **Factual accuracy** and details
61
+ - **Natural flow** of conversation
62
+
63
+ ## Design Principles
64
+
65
+ 1. **Light Touch Editing**: Minimal intervention while maximizing clarity
66
+ 2. **Content Preservation**: Never removes or alters important information
67
+ 3. **Deterministic Guidance**: Consistent, predictable results
68
+ 4. **Purpose Agnostic**: Works across all content domains
69
+ 5. **Modular Foundation**: Ready for specialized prompt layering
70
+
71
+ ## Extended Ecosystem
72
+
73
+ This basic cleanup prompt is part of a larger ecosystem:
74
+ - **Hundreds of specialized prompts** available in shared libraries
75
+ - **Domain-specific transformations** for various use cases
76
+ - **Concatenation-ready design** for complex workflows
77
+ - **Shared on Hugging Face** and other platforms
78
+
79
+ ## System Prompt
80
+
81
+ The tool uses a carefully crafted system prompt (Version 3, September 2025) that balances cleanup effectiveness with content preservation. View the complete prompt using the "Show System Prompt" feature in the interface.
82
+ """
83
+
84
+ def cleanup_transcript(text, api_key):
85
+ """Clean up STT transcript using OpenAI API"""
86
+ if not text.strip():
87
+ return "Please provide text to clean up."
88
+
89
+ if not api_key.strip():
90
+ return "Please provide your OpenAI API key."
91
+
92
+ try:
93
+ client = OpenAI(api_key=api_key)
94
+
95
+ response = client.chat.completions.create(
96
+ model="gpt-4o-mini", # Using cost-effective model
97
+ messages=[
98
+ {"role": "system", "content": SYSTEM_PROMPT},
99
+ {"role": "user", "content": text}
100
+ ],
101
+ temperature=0.3,
102
+ max_tokens=4000
103
+ )
104
+
105
+ cleaned_text = response.choices[0].message.content
106
+ return cleaned_text
107
+
108
+ except Exception as e:
109
+ return f"Error: {str(e)}"
110
+
111
+ def copy_to_clipboard_js():
112
+ """JavaScript function to copy text to clipboard"""
113
+ return """
114
+ function copyToClipboard(text) {
115
+ navigator.clipboard.writeText(text).then(function() {
116
+ // You could add a toast notification here
117
+ });
118
+ }
119
+ """
120
+
121
+ # Create the Gradio interface
122
+ with gr.Blocks(
123
+ title="STT Transcript Cleanup Tool",
124
+ theme=gr.themes.Soft(),
125
+ css="""
126
+ .main-header {
127
+ text-align: center;
128
+ margin-bottom: 2rem;
129
+ }
130
+ .attribution {
131
+ text-align: center;
132
+ margin-top: 2rem;
133
+ padding: 1rem;
134
+ background-color: #f8f9fa;
135
+ border-radius: 8px;
136
+ }
137
+ """
138
+ ) as demo:
139
+
140
+ gr.HTML("""
141
+ <div class="main-header">
142
+ <h1>🎤 STT Transcript Cleanup Tool</h1>
143
+ <p>Clean up speech-to-text transcripts by removing filler words, adding punctuation, and improving readability.</p>
144
+ <p><strong>Note:</strong> This tool requires your own OpenAI API key (BYOK - Bring Your Own Key)</p>
145
+ </div>
146
+ """)
147
+
148
+ with gr.Tabs():
149
+ with gr.TabItem("Cleanup Tool"):
150
+ with gr.Row():
151
+ with gr.Column():
152
+ api_key_input = gr.Textbox(
153
+ label="OpenAI API Key",
154
+ placeholder="sk-...",
155
+ type="password",
156
+ info="Your API key is not stored and only used for this session"
157
+ )
158
+
159
+ input_text = gr.Textbox(
160
+ label="Raw STT Transcript",
161
+ placeholder="Paste your speech-to-text transcript here...",
162
+ lines=10,
163
+ max_lines=20
164
+ )
165
+
166
+ with gr.Row():
167
+ cleanup_btn = gr.Button("Clean Up Transcript", variant="primary")
168
+ clear_btn = gr.Button("Clear", variant="secondary")
169
+
170
+ with gr.Column():
171
+ output_text = gr.Textbox(
172
+ label="Cleaned Transcript",
173
+ lines=10,
174
+ max_lines=20,
175
+ interactive=False
176
+ )
177
+
178
+ with gr.Row():
179
+ copy_btn = gr.Button("Copy to Clipboard", variant="secondary")
180
+ rerun_btn = gr.Button("Run Again", variant="secondary")
181
+
182
+ with gr.TabItem("System Prompt"):
183
+ gr.Markdown("## Current System Prompt")
184
+ gr.Markdown("This is the prompt used to instruct the AI on how to clean up your transcripts:")
185
+ gr.Code(SYSTEM_PROMPT_CONTENT, language="markdown", label="system-prompt.md")
186
+
187
+ with gr.TabItem("About"):
188
+ gr.Markdown(README_CONTENT)
189
+
190
+ # Event handlers
191
+ cleanup_btn.click(
192
+ fn=cleanup_transcript,
193
+ inputs=[input_text, api_key_input],
194
+ outputs=output_text
195
+ )
196
+
197
+ rerun_btn.click(
198
+ fn=cleanup_transcript,
199
+ inputs=[input_text, api_key_input],
200
+ outputs=output_text
201
+ )
202
+
203
+ clear_btn.click(
204
+ fn=lambda: ("", ""),
205
+ outputs=[input_text, output_text]
206
+ )
207
+
208
+ # Copy to clipboard functionality
209
+ copy_btn.click(
210
+ fn=None,
211
+ inputs=output_text,
212
+ outputs=None,
213
+ js="(text) => navigator.clipboard.writeText(text)"
214
+ )
215
+
216
+ # Attribution
217
+ gr.HTML("""
218
+ <div class="attribution">
219
+ <p><strong>Created by:</strong> <a href="https://danielrosehill.com" target="_blank">Daniel Rosehill</a></p>
220
+ <p>This tool helps clean up speech-to-text transcripts by removing filler words, adding proper punctuation,
221
+ and improving overall readability while preserving the original meaning and important details.</p>
222
+ </div>
223
+ """)
224
+
225
+ if __name__ == "__main__":
226
+ demo.launch()
icon.jpg ADDED

Git LFS Details

  • SHA256: 0bf423937648c0372fa673a6259fd868ffda5cfbf4bd33565827e216a1b5681e
  • Pointer size: 131 Bytes
  • Size of remote file: 118 kB
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio==4.44.0
2
+ openai==1.51.0
system-prompt.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Speech To Text (STT): Basic Text Cleanup / Remediation Prompt: V3 (28/Sep/2025)
2
+
3
+ You are a helpful writing assistant.
4
+
5
+ Your purpose is to lightly edit texts provided by the user. The texts which you will be receiving were generated using speech to text technology. Your function is to lightly edit the texts to improve their readability and intelligibility.
6
+
7
+ Your overarching objective is to take "raw" text and reformat it for readiability.
8
+
9
+ ## Editing Instructions
10
+
11
+ You should apply the following set of remediations:
12
+
13
+ - Remove filler words (like "um")
14
+ - If you can infer instructions to omit certain clauses from the edited transcript you will produce (For example: "wait .. scratch that from the note") then follow the inferred instruction
15
+ - Add punctuation, sentence structure, and paragraph spacing'
16
+
17
+ You may encounter, in the source text, obvious hallucinations or mistranscriptions. If you encounter either, infer the intended meaning rather than the version in the transcript.
18
+
19
+ Beyond these basic fixes, you should edit the text lightly to omit repetitive or run on thoughts where words are repeated that would not be helpful in transcript. For example if the raw transcript read: "I want go to the cinema today to ... see ... to see ... the movie .. the movie ... Shrek" you would edit that to "I want to go to the cinema today to see the movie Shrek."
20
+
21
+ Do not edit the transcript beyond these basic fixes. Assume that all details in the transcipt are important and must be preserved.
22
+
23
+ ## Workflow
24
+
25
+ You adhere to the following workflow:
26
+
27
+ The user will provide the text (you can infer that any long text prompted carries the implicit instruction to please apply your edirts).
28
+
29
+ In response: you reply with the full remediated text without any prefixing or suffixing content or messages to the user.