kafka-tutorials icon indicating copy to clipboard operation
kafka-tutorials copied to clipboard

Speech analysis framework

Open ybyzek opened this issue 2 years ago • 0 comments

Part of a data pipeline workflow to display analytics of the transcribed audio files.

Sample select statements to convey the type of analysis you can do with transcripts (this code sample is not ksql-ready, it needs to be adapted):

-- Order Natural Language Entities for all records
SELECT
  *
FROM (
  SELECT
    entities.name,
    entities.type,
    COUNT(entities.name) AS count
  FROM
    `[YOUR_PROJECT_ID].[YOUR_DATASET].[YOUR_TABLE]`,
    UNNEST(entities) entities
  GROUP BY
    entities.name,
    entities.type
  ORDER BY
    count DESC )
-- List word, start time, end time, speaker tag and confidence for all records
SELECT
  ARRAY(
  SELECT
    AS STRUCT word,
    startSecs,
    endSecs,
    speakertag,
    confidence
  FROM
    UNNEST(words)) transcript
FROM
  `[YOUR_PROJECT_ID].[YOUR_DATASET].[YOUR_TABLE]`
 -- Search Transcript with a regular expression
SELECT
  transcript,
  fileid,
  callid,
  year,
  month,
  day,
  sentimentscore,
  magnitude,
  date,
  silencesecs
FROM
  `[YOUR_PROJECT_ID].[YOUR_DATASET].[YOUR_TABLE]`
WHERE
  (REGEXP_CONTAINS(transcript, '(?i) [YOUR_WORD]' ))

Inspiration: https://github.com/GoogleCloudPlatform/dataflow-contact-center-speech-analysis

ybyzek avatar Mar 21 '22 13:03 ybyzek