Make Whisper transcripts editable, add use-as-text-to-speak button
Real workflow gap: the transcript boxes were read-only, so correcting a
mis-hearing meant manually retyping into the separate Text to speak
field. Reported case: uploading a clip with casual speech ("its
gonna") transcribed as "it is going to be" - if that formalized text
then gets used for generation (by copying it over by hand, the only
option available), the cloned voice ends up speaking noticeably more
formally than intended.
Both transcript boxes are now editable, and thereas a direct "Use this
transcript as Text to speak" button on the reference transcript so a
corrected transcript can be sent straight into generation without
retyping. Also bumped the Whisper model from small to medium for
somewhat better fidelity on casual speech - a real but modest
improvement on the one comparison run, not a guaranteed fix, which is
why the editable box is the actual fix and the model bump is a bonus.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1oQ4h4WE4R9KRvMQLr5Ey
This commit is contained in:
1 parent
d890736445
commit
2bc1cbf6d6
1 file changed
+15
-3
+15
-3
@@ -181,7 +181,14 @@ def _whisper_transcribe(path: str) -> str:
|
||||
try:
|
||||
if _whisper_model is None:
|
||||
from faster_whisper import WhisperModel
|
||||
_whisper_model = WhisperModel("small", device="cpu", compute_type="int8")
|
||||
# "small" mis-heard casual contractions as formal phrasing on
|
||||
# short/quiet clips (e.g. "it's gonna" -> "it is going to be") -
|
||||
# "medium" is noticeably more faithful to actual speech patterns
|
||||
# at the cost of a few more seconds per transcription on CPU,
|
||||
# worth it since this check exists specifically to catch content
|
||||
# problems - a transcript that itself distorts casual speech
|
||||
# defeats that purpose.
|
||||
_whisper_model = WhisperModel("medium", device="cpu", compute_type="int8")
|
||||
segments, _ = _whisper_model.transcribe(path, language="en", beam_size=5)
|
||||
return " ".join(s.text.strip() for s in segments)
|
||||
except Exception as e:
|
||||
@@ -625,7 +632,11 @@ with gr.Blocks(title="Audio-demo pipeline studio") as demo:
|
||||
with gr.Column():
|
||||
gr.Markdown("## 2. Voice editor (AuK)")
|
||||
current_ref_audio = gr.Audio(label="Current reference", type="filepath", interactive=False)
|
||||
ref_transcript_box = gr.Textbox(label="Whisper transcript of current reference", interactive=False)
|
||||
ref_transcript_box = gr.Textbox(
|
||||
label="Whisper transcript of current reference (editable - fix any mis-hearing before using it)",
|
||||
info="Whisper can mishear casual speech as more formal phrasing on short/quiet clips (e.g. \"it's gonna\" -> \"it is going to be\") - correct it here before sending it anywhere.",
|
||||
)
|
||||
use_ref_transcript_btn = gr.Button("Use this transcript as 'Text to speak' →")
|
||||
history_label = gr.Markdown("No reference set yet.")
|
||||
model_dd = gr.Radio(
|
||||
[MODEL_BASE, MODEL_FLASH], value=MODEL_BASE, label="AuK model",
|
||||
@@ -702,7 +713,7 @@ with gr.Blocks(title="Audio-demo pipeline studio") as demo:
|
||||
gen_language = gr.Dropdown(LANGUAGES, value="English", label="Language")
|
||||
generate_btn = gr.Button("Generate speech", variant="primary")
|
||||
generated_audio = gr.Audio(label="Generated speech", type="filepath")
|
||||
gen_transcript_box = gr.Textbox(label="Whisper transcript", interactive=False)
|
||||
gen_transcript_box = gr.Textbox(label="Whisper transcript of generated speech")
|
||||
|
||||
gr.Markdown("## 4. Save as a the-service-station character")
|
||||
new_char_name = gr.Textbox(label="Name")
|
||||
@@ -743,6 +754,7 @@ with gr.Blocks(title="Audio-demo pipeline studio") as demo:
|
||||
generate_speech, inputs=[current_ref_audio, gen_text, gen_language],
|
||||
outputs=[generated_audio, gen_transcript_box],
|
||||
)
|
||||
use_ref_transcript_btn.click(lambda t: t, inputs=[ref_transcript_box], outputs=[gen_text])
|
||||
save_char_btn.click(
|
||||
create_character,
|
||||
inputs=[new_char_name, new_char_role, new_char_prose, gen_language, current_ref_audio, history_state],
|
||||
|
||||
Reference in new issue
Block a user