diff --git a/CHANGELOG.md b/CHANGELOG.md index 628197b1..f3f934b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to - ✨(frontend) allow disabling silent login via a URL parameter - ✨(frontend) allow hiding the login button via a URL parameter +- ✨(summary) add optional satisfaction survey footer ### Changed diff --git a/env.d/development/summary.dist b/env.d/development/summary.dist index f69b9fd5..ab83a629 100644 --- a/env.d/development/summary.dist +++ b/env.d/development/summary.dist @@ -22,3 +22,6 @@ WEBHOOK_URL="https://configure-your-url.com" POSTHOG_API_KEY="your-posthog-key" POSTHOG_ENABLED="False" + +# Transcription +TRANSCRIPTION_SATISFACTION_FORM_BASE_URL= diff --git a/src/summary/summary/core/celery_worker.py b/src/summary/summary/core/celery_worker.py index 567c67e9..944b1d46 100644 --- a/src/summary/summary/core/celery_worker.py +++ b/src/summary/summary/core/celery_worker.py @@ -233,6 +233,7 @@ def format_transcript( recording_datetime: str | None, owner_timezone: str | None, download_link: str | None, + form_link: str | None, ) -> tuple[str, str]: """Format a transcription into readable content with a title. @@ -250,6 +251,7 @@ def format_transcript( recording_datetime=recording_datetime, owner_timezone=owner_timezone, download_link=download_link, + form_link=form_link, ) @@ -346,6 +348,13 @@ def process_audio_transcribe_summarize_v2( task_id, ) + form_base_url = settings.transcription_satisfaction_form_base_url + form_link = ( + f"{form_base_url}?room_id={room}" + if (form_base_url and metadata_filename is not None) + else None + ) + # Format output content, title = format_transcript( transcription, @@ -355,6 +364,7 @@ def process_audio_transcribe_summarize_v2( recording_start_at, owner_timezone, download_link, + form_link, ) submit_content(content, title, email, sub) diff --git a/src/summary/summary/core/config.py b/src/summary/summary/core/config.py index 1e001003..28a4a44e 100644 --- a/src/summary/summary/core/config.py +++ b/src/summary/summary/core/config.py @@ -122,6 +122,7 @@ class Settings(BaseSettings): # Summary related settings is_summary_enabled: bool = True + transcription_satisfaction_form_base_url: Optional[str] = None # Sentry sentry_is_enabled: bool = False diff --git a/src/summary/summary/core/locales/de.py b/src/summary/summary/core/locales/de.py index 9d13f413..10a8d2c7 100644 --- a/src/summary/summary/core/locales/de.py +++ b/src/summary/summary/core/locales/de.py @@ -25,6 +25,10 @@ Einige Punkte, die wir Ihnen empfehlen zu überprüfen: download_header_template=( "\n*[Laden Sie hier Ihre Aufnahme herunter (externer Link)]({download_link})*\n" ), + form_footer_template=( + "\n\n*[Teilen Sie uns mit, wie Ihnen diese Transkription gefallen hat " + "(externer Link)]({form_link})*\n" + ), hallucination_replacement_text="[Text konnte nicht transkribiert werden]", document_default_title="Transkription", document_title_template=( diff --git a/src/summary/summary/core/locales/en.py b/src/summary/summary/core/locales/en.py index a70ef1a9..22841d84 100644 --- a/src/summary/summary/core/locales/en.py +++ b/src/summary/summary/core/locales/en.py @@ -25,6 +25,10 @@ A few things we recommend you check: download_header_template=( "\n*[Download your recording (external link)]({download_link})*\n" ), + form_footer_template=( + "\n\n*[Tell us what you thought of this transcription " + "(external link)]({form_link})*\n" + ), hallucination_replacement_text="[Unable to transcribe text]", document_default_title="Transcription", document_title_template=( diff --git a/src/summary/summary/core/locales/fr.py b/src/summary/summary/core/locales/fr.py index 21214176..aab29617 100644 --- a/src/summary/summary/core/locales/fr.py +++ b/src/summary/summary/core/locales/fr.py @@ -25,6 +25,9 @@ Quelques points que nous vous conseillons de vérifier : download_header_template=( "\n*[Télécharger votre enregistrement Audio]({download_link})*\n" ), + form_footer_template=( + "\n\n*[Donnez nous votre avis sur cette transcription]({form_link})*\n" + ), hallucination_replacement_text="[Texte impossible à transcrire]", document_default_title="Transcription", document_title_template=( diff --git a/src/summary/summary/core/locales/nl.py b/src/summary/summary/core/locales/nl.py index d57e6cd5..3da0de7e 100644 --- a/src/summary/summary/core/locales/nl.py +++ b/src/summary/summary/core/locales/nl.py @@ -25,6 +25,10 @@ Een paar punten die wij u aanraden te controleren: download_header_template=( "\n*[Download hier je opname (externe link)]({download_link})*\n" ), + form_footer_template=( + "\n\n*[Laat ons weten wat je van deze transcriptie vond " + "(externe link)]({form_link})*\n" + ), hallucination_replacement_text="[Tekst kon niet worden getranscribeerd]", document_default_title="Transcriptie", document_title_template=( diff --git a/src/summary/summary/core/locales/strings.py b/src/summary/summary/core/locales/strings.py index c182cfdf..77a20979 100644 --- a/src/summary/summary/core/locales/strings.py +++ b/src/summary/summary/core/locales/strings.py @@ -10,6 +10,7 @@ class LocaleStrings: # transcript_formatter.py empty_transcription: str download_header_template: str + form_footer_template: str hallucination_replacement_text: str document_default_title: str document_title_template: str diff --git a/src/summary/summary/core/transcript_formatter.py b/src/summary/summary/core/transcript_formatter.py index 4dec9e33..be1ff53e 100644 --- a/src/summary/summary/core/transcript_formatter.py +++ b/src/summary/summary/core/transcript_formatter.py @@ -38,13 +38,14 @@ class TranscriptFormatter: return None - def format( + def format( # noqa: PLR0913 self, transcription, room: str | None = None, recording_datetime: str | None = None, owner_timezone: str | None = None, download_link: str | None = None, + form_link: str | None = None, ) -> Tuple[str, str]: """Format transcription into the final document and its title.""" segments = self._get_segments(transcription) @@ -55,6 +56,8 @@ class TranscriptFormatter: content = self._format_speaker(segments) content = self._remove_hallucinations(content) content = self._add_header(content, download_link) + if form_link: + content = self._add_footer(content, form_link) title = self._generate_title(room, recording_datetime, owner_timezone) @@ -93,9 +96,14 @@ class TranscriptFormatter: header = self._locale.download_header_template.format( download_link=download_link ) - content = header + content + return header + content - return content + def _add_footer(self, content, form_link: str | None): + if not form_link: + return content + + footer = self._locale.form_footer_template.format(form_link=form_link) + return content + footer def _generate_title( self, diff --git a/src/summary/tests/api/test_api_tasks.py b/src/summary/tests/api/test_api_tasks.py index 07bffd1b..98ef066b 100644 --- a/src/summary/tests/api/test_api_tasks.py +++ b/src/summary/tests/api/test_api_tasks.py @@ -27,6 +27,7 @@ class TestTasks: "owner_timezone": "UTC", "language": None, "download_link": "https://example.com/file.mp4", + "form_link": "https://satisfaction.com?room_id=test", }, )