forked from rai-project/mlmodelscope
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding text-to-audio task * removed a console log * misc styling updates * Removed some commented out code
- Loading branch information
1 parent
ffc5eb5
commit 56ab90c
Showing
17 changed files
with
252 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/components/Experiment/QuickOutput/Outputs/AudioToText/AudioToText.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.audio-to-text-output { | ||
&__input-audio-content { | ||
audio { | ||
margin-top: 12px; | ||
} | ||
} | ||
} |
4 changes: 1 addition & 3 deletions
4
src/components/Experiment/QuickOutput/Outputs/AudioToText/AudioToTextOutputInputSection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/components/Experiment/QuickOutput/Outputs/TextToAudio/AudioOutputBox.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import useBEMNaming from "../../../../../common/useBEMNaming"; | ||
import OutputDuration from "../_Common/components/OutputDuration"; | ||
import Rating from "../Classification/Rating"; | ||
import React from "react"; | ||
import Task from "../../../../../helpers/Task"; | ||
import { textToText } from "../../../../../helpers/TaskIDs"; | ||
import DownloadIcon from "../../../../../resources/icons/icon-download.png" | ||
|
||
export function AudioOutputBox(props) { | ||
const { getElement } = useBEMNaming("text-to-audio-output"); | ||
const task = props.task ? Task.getStaticTask(props.task) : Task.getStaticTask(textToText); | ||
|
||
|
||
console.log(props) | ||
return ( | ||
<div className={getElement("results")}> | ||
<div className={getElement("title-row")}> | ||
<h3 className={getElement("title-row-title")}> | ||
Output | ||
</h3> | ||
<OutputDuration duration={props.duration} /> | ||
</div> | ||
<p className={getElement("subtitle")}> | ||
{task.outputText} | ||
</p> | ||
<div | ||
className={getElement("output-container output-container-background")} | ||
> | ||
<div className="output-audio-content audio-container"> | ||
<audio controls src={props.output.src} /> | ||
<a download={props.output.title} href={props.output.src}> | ||
<img className="download-audio-icon" src={DownloadIcon} /> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<Rating /> | ||
</div> | ||
); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/components/Experiment/QuickOutput/Outputs/TextToAudio/TextToAudioOutput.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from "react"; | ||
import useBEMNaming from "../../../../../common/useBEMNaming"; | ||
import useTextOutput from "../Text/useTextOutput"; | ||
|
||
import { AudioOutputBox } from "./AudioOutputBox"; | ||
import TextOutputInputSection from "../Text/TextOutputInputSection"; | ||
|
||
import { textToAudio } from "../../../../../helpers/TaskIDs"; | ||
export default function TextToAudioOutput(props) { | ||
const { getBlock } = useBEMNaming("text-to-audio-output"); | ||
|
||
// Note: This method could probably be renamed to a more generic 'useOutput' or similar? | ||
const { output, inferenceDuration, input, setInput } = useTextOutput( | ||
props.trial | ||
); | ||
|
||
const onSubmit = () => { | ||
props.onSubmit(input); | ||
}; | ||
|
||
return ( | ||
<div className={getBlock()}> | ||
<TextOutputInputSection | ||
input={input} | ||
setInput={setInput} | ||
onSubmit={onSubmit} | ||
/> | ||
<AudioOutputBox duration={inferenceDuration} output={output} task={textToAudio} /> | ||
</div> | ||
); | ||
} |
13 changes: 13 additions & 0 deletions
13
src/components/Experiment/QuickOutput/Outputs/TextToAudio/TextToAudioOutput.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from "react"; | ||
import TextToAudioOutput from "./TextToAudioOutput"; | ||
import { TestTextToAudioOutput } from "./testData/testTextToAudioOutput"; | ||
|
||
export default { | ||
title: "Experiments/Quick Output/Text to Audio", | ||
component: TextToAudioOutput, | ||
}; | ||
|
||
const template = (args) => <TextToAudioOutput {...args} />; | ||
|
||
export const Default = template.bind({}); | ||
Default.args = { trial: TestTextToAudioOutput }; |
27 changes: 27 additions & 0 deletions
27
src/components/Experiment/QuickOutput/Outputs/TextToAudio/testData/testTextToAudioOutput.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export const TestTextToAudioOutputGeneratedToken = { | ||
id: "sampleidhere" | ||
}; | ||
|
||
export const TestTextToAudioOutput = { | ||
id: "sampletesttexttoaudiooutputidhere", | ||
inputs: [ | ||
'a chill song with influences from lofi, chillstep and downtempo', | ||
], | ||
completed_at: "2023-06-03T18:17:14.513854Z", | ||
results: { | ||
'duration': "9.216154124s", | ||
'duration_for_inference': "9.193807904s", | ||
'responses': [ | ||
{ | ||
'features': [ | ||
{ | ||
title: "text-to-audio-output.flac", | ||
src: "https://xlab1.netlify.app/text-to-audio-output.flac", | ||
type: 'AUDIO' | ||
} | ||
], | ||
'id': "sampletesttexttoaudiooutputresponseidhere" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.