Skip to content

Commit

Permalink
Merge pull request #361 from AppQuality/develop
Browse files Browse the repository at this point in the history
Improve video cutting and add debounce to bookmark update
  • Loading branch information
cannarocks authored May 21, 2024
2 parents 56e5be8 + 2fc0524 commit 3ca28db
Show file tree
Hide file tree
Showing 12 changed files with 280 additions and 22 deletions.
11 changes: 11 additions & 0 deletions src/assets/icons/sentiment-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/assets/icons/sentiment-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/assets/icons/sentiment-3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/assets/icons/sentiment-4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/assets/icons/sentiment-5.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 26 additions & 2 deletions src/stories/highlight/demo-parts/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3653,6 +3653,7 @@ export const DemoTranscript = {
num_words: 147,
start: 55.68,
end: 120.93,
sentiment: 4
},
{
sentences: [
Expand All @@ -3666,6 +3667,7 @@ export const DemoTranscript = {
num_words: 48,
start: 122.75,
end: 142.36499,
sentiment: 4
},
{
sentences: [
Expand All @@ -3679,6 +3681,8 @@ export const DemoTranscript = {
num_words: 1,
start: 143.22499,
end: 143.72499,
sentiment: 3

},
{
sentences: [
Expand All @@ -3702,6 +3706,7 @@ export const DemoTranscript = {
num_words: 24,
start: 146.98999,
end: 159.355,
sentiment: 4
},
{
sentences: [
Expand All @@ -3715,6 +3720,7 @@ export const DemoTranscript = {
num_words: 5,
start: 160.92,
end: 167.73999,
sentiment: 3
},
{
sentences: [
Expand All @@ -3728,6 +3734,7 @@ export const DemoTranscript = {
num_words: 17,
start: 168.765,
end: 176.94499,
sentiment: 3
},
{
sentences: [
Expand All @@ -3740,7 +3747,8 @@ export const DemoTranscript = {
speaker: 1,
num_words: 13,
start: 177.85,
end: 184.25,
end: 184.25,
sentiment: 3
},
{
sentences: [
Expand All @@ -3754,6 +3762,7 @@ export const DemoTranscript = {
num_words: 4,
start: 184.25,
end: 186.27,
sentiment: 3
},
{
sentences: [
Expand All @@ -3772,6 +3781,7 @@ export const DemoTranscript = {
num_words: 7,
start: 190.015,
end: 191.955,
sentiment: 3
},
{
sentences: [
Expand All @@ -3785,6 +3795,7 @@ export const DemoTranscript = {
num_words: 24,
start: 192.33499,
end: 206.02,
sentiment: 3
},
{
sentences: [
Expand All @@ -3798,6 +3809,7 @@ export const DemoTranscript = {
num_words: 58,
start: 208.065,
end: 247.195,
sentiment: 3
},
{
sentences: [
Expand All @@ -3811,6 +3823,7 @@ export const DemoTranscript = {
num_words: 6,
start: 249.7,
end: 252.2,
sentiment: 3
},
{
sentences: [
Expand All @@ -3824,6 +3837,7 @@ export const DemoTranscript = {
num_words: 27,
start: 254.98,
end: 280.595,
sentiment: 2
},
{
sentences: [
Expand All @@ -3837,6 +3851,7 @@ export const DemoTranscript = {
num_words: 8,
start: 282.21,
end: 286.79,
sentiment: 3
},
{
sentences: [
Expand All @@ -3850,6 +3865,7 @@ export const DemoTranscript = {
num_words: 5,
start: 289.64502,
end: 293.665,
sentiment: 3
},
{
sentences: [
Expand All @@ -3863,6 +3879,7 @@ export const DemoTranscript = {
num_words: 10,
start: 295.223,
end: 299.723,
sentiment: 3
},
],
},
Expand All @@ -3871,4 +3888,11 @@ export const DemoTranscript = {
},
],
},
};
};


export const DemoSentiment = {
role: "assistant",
rate: 4,
content: "The reason for this rating is that the tone of the text is overall polite, professional, and cooperative. The speaker expresses gratitude, ensures the participant feels comfortable, and clearly explains the purpose and process of the meeting. There is an emphasis on open communication, feedback, and collaboration, which creates a positive and constructive atmosphere. The overall attitude and approach towards the interaction appear positive and respectful."
}
77 changes: 77 additions & 0 deletions src/stories/highlight/demo-parts/sentiment-tag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { theme } from "../../theme";
import { Span } from "../../typography/span";
import { ReactComponent as Sentiment1 } from "../../../assets/icons/sentiment-1.svg";
import { ReactComponent as Sentiment2 } from "../../../assets/icons/sentiment-2.svg";
import { ReactComponent as Sentiment3 } from "../../../assets/icons/sentiment-3.svg";
import { ReactComponent as Sentiment4 } from "../../../assets/icons/sentiment-4.svg";
import { ReactComponent as Sentiment5 } from "../../../assets/icons/sentiment-5.svg";
import styled from "styled-components";

const StyledDiv = styled.div`
svg {
width: ${({ theme }) => theme.space.sm};
height: ${({ theme }) => theme.space.sm};
margin-right: ${(p) => p.theme.space.xs};
flex-shrink: 0;
}
`;

export const getSentiment = (value: number) => {
switch (value) {
case 1:
return {
color: theme.palette.red[500],
text: (
<StyledDiv>
<Sentiment1 />{" "}
<Span style={{ whiteSpace: "nowrap" }}>Very Negative</Span>
</StyledDiv>
),
};
case 2:
return {
color: theme.palette.red[500],
text: (
<StyledDiv>
<Sentiment2 />{" "}
<Span style={{ whiteSpace: "nowrap" }}>Negative</Span>
</StyledDiv>
),
};
case 3:
return {
color: theme.palette.yellow[500],
text: (
<StyledDiv>
<Sentiment3 /> <Span style={{ whiteSpace: "nowrap" }}>Neutral</Span>
</StyledDiv>
),
};
case 4:
return {
color: theme.palette.green[500],
text: (
<StyledDiv>
<Sentiment4 />{" "}
<Span style={{ whiteSpace: "nowrap" }}>Positive</Span>
</StyledDiv>
),
};
case 5:
return {
color: theme.palette.green[500],
text: (
<StyledDiv>
<Sentiment5 />{" "}
<Span style={{ whiteSpace: "nowrap" }}>Very Positive</Span>
</StyledDiv>
),
};

default:
return {
color: theme.palette.yellow[500],
text: "",
};
}
};
71 changes: 71 additions & 0 deletions src/stories/highlight/demo-parts/transcript-sentiment.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { styled } from "styled-components";
import { Highlight } from "..";
import { formatDuration } from "../../player/parts/utils";
import { SM } from "../../typography/typescale";
import { StoryArgs } from "../index.stories";
import { DemoTranscript as demo, DemoSentiment } from "./data";
import { getSentiment } from "./sentiment-tag";
import { Textarea } from "../../forms/textarea";

const StyledDiv = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: ${({ theme }) => theme.space.sm};
`;

export const TSentiment = (
args: StoryArgs & { currentTime: number; offset: number }
) => {
const words = demo.results.channels[0].alternatives[0].words.map((w) => ({
word: w.punctuated_word,
start: w.start,
end: w.end,
speaker: w.speaker,
}));
const paragraphs =
demo.results.channels[0].alternatives[0].paragraphs.paragraphs.map((w) => ({
words: words.filter((word) => word.start >= w.start && word.end <= w.end),
start: w.start,
end: w.end,
speaker: w.speaker,
text: w.sentences.map((s) => s.text).join(" "),
sentiment: w.sentiment,
}));
return (
<Highlight {...args}>
Overall: 4 - Positive
<Textarea
readOnly
disabled
style={{ margin: 0 }}
value={DemoSentiment.content}
rows={4}
/>
<br />
<br />
{paragraphs.map((p, index) => (
<div style={{ marginBottom: "8px" }}>
<StyledDiv>
<SM>
<b>{p.speaker === 1 ? "Tester" : "Interviewer"}</b>&nbsp; (
{formatDuration(p.start - args.offset)} -{" "}
{formatDuration(p.end - args.offset)})
</SM>
{p.sentiment && getSentiment(p.sentiment).text}
</StyledDiv>
{p.words.map((w) => (
<Highlight.Word
key={index}
start={w.start}
end={w.end}
currentTime={args.currentTime}
text={w.word}
/>
))}
</div>
))}
</Highlight>
);
};
12 changes: 12 additions & 0 deletions src/stories/highlight/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Transcript } from "./demo-parts/transcript-base";
import { TDiarization } from "./demo-parts/transcript-diarization";
import { TParagraph } from "./demo-parts/transcript-paragraph";
import { Tag } from "../tags";
import { TSentiment } from "./demo-parts/transcript-sentiment";

export interface StoryArgs extends HighlightArgs {
words: Array<WordProps & { speaker: number }>;
Expand Down Expand Up @@ -632,6 +633,17 @@ const DemoTemplate: StoryFn<StoryArgs> = (args) => {
offset={VIDEO_OFFSET}
/>
</Tabs.Panel>
<Tabs.Panel
className={"tab-panel-4"}
key={"tab-panel-4"}
title={"Meta"}
>
<TSentiment
{...args}
currentTime={currentTime}
offset={VIDEO_OFFSET}
/>
</Tabs.Panel>
</Tabs>
</Col>
</Row>
Expand Down
Loading

0 comments on commit 3ca28db

Please sign in to comment.