Skip to content

Commit

Permalink
Adding support for zoom plugin summarization of chats and transcripti…
Browse files Browse the repository at this point in the history
…ons (#184)

* Adding support for zoom plugin summarization of chats and transcriptions

* Fixing CI

* Addressing PR review comments

* Fixing build
  • Loading branch information
jespino authored Jun 7, 2024
1 parent 36d4c72 commit ad2dc86
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
33 changes: 33 additions & 0 deletions server/ai/subtitles/subtitles.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package subtitles

import (
"bufio"
"fmt"
"io"
"strings"
Expand All @@ -13,6 +14,38 @@ type Subtitles struct {
storage *astisub.Subtitles
}

func readZoomChat(chat io.Reader) (*astisub.Subtitles, error) {
storage := astisub.NewSubtitles()

scanner := bufio.NewScanner(chat)
for scanner.Scan() {
line := scanner.Text()
text := line[9:]
item := &astisub.Item{}
startAt, err := time.Parse("15:04:05", line[:8])
if err != nil {
return nil, err
}
zeroTime, err := time.Parse("15:04:05", "00:00:00")
if err != nil {
return nil, err
}
item.StartAt = startAt.Sub(zeroTime)
item.EndAt = startAt.Add(5 * time.Second).Sub(zeroTime)
item.Lines = append(item.Lines, astisub.Line{Items: []astisub.LineItem{{Text: text}}})
storage.Items = append(storage.Items, item)
}
return storage, nil
}

func NewSubtitlesFromZoomChat(chat io.Reader) (*Subtitles, error) {
storage, err := readZoomChat(chat)
if err != nil {
return nil, err
}
return &Subtitles{storage: storage}, nil
}

func NewSubtitlesFromVTT(webvtt io.Reader) (*Subtitles, error) {
storage, err := astisub.ReadFromWebVTT(webvtt)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions server/api_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ func (p *Plugin) handleSummarizeTranscription(c *gin.Context) {
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("unable to get calls user: %w", err))
return
}
if !targetPostUser.IsBot || targetPostUser.Username != CallsBotUsername {
c.AbortWithError(http.StatusBadRequest, errors.New("not a calls bot post"))
if !targetPostUser.IsBot || (targetPostUser.Username != CallsBotUsername && targetPostUser.Username != ZoomBotUsername) {
c.AbortWithError(http.StatusBadRequest, errors.New("not a calls or zoom bot post"))
return
}

Expand Down
14 changes: 11 additions & 3 deletions server/meeting_summarization.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,17 @@ func (p *Plugin) newCallTranscriptionSummaryThread(bot *Bot, requestingUser *mod
return fmt.Errorf("unable to read calls file: %w", err)
}

transcription, err := subtitles.NewSubtitlesFromVTT(transcriptionFileReader)
if err != nil {
return fmt.Errorf("unable to parse transcription file: %w", err)
var transcription *subtitles.Subtitles
if transcriptionFilePost.Type == "custom_zoom_chat" {
transcription, err = subtitles.NewSubtitlesFromZoomChat(transcriptionFileReader)
if err != nil {
return fmt.Errorf("unable to parse transcription file: %w", err)
}
} else {
transcription, err = subtitles.NewSubtitlesFromVTT(transcriptionFileReader)
if err != nil {
return fmt.Errorf("unable to parse transcription file: %w", err)
}
}

context := p.MakeConversationContext(bot, requestingUser, channel, nil)
Expand Down
1 change: 1 addition & 0 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (

CallsRecordingPostType = "custom_calls_recording"
CallsBotUsername = "calls"
ZoomBotUsername = "zoom"

ffmpegPluginPath = "./plugins/mattermost-ai/server/dist/ffmpeg"
)
Expand Down

0 comments on commit ad2dc86

Please sign in to comment.