Clean build

This commit is contained in:
Hayk Martiros 2022-11-27 16:59:00 -08:00
parent 5cf6c476ab
commit e51c7d3129
4 changed files with 25 additions and 16 deletions

View File

@ -132,6 +132,7 @@ export default function AudioPlayer({
resultCounter,
inferenceResults,
paused,
nowPlayingCallback,
tonePlayer,
]);

View File

@ -1,6 +1,5 @@
import { useRouter } from "next/router";
import { useCallback, useEffect, useState } from "react";
import { useInterval } from "usehooks-ts";
import {
AppState,
@ -18,7 +17,6 @@ interface ModelInferenceProps {
appState: AppState;
promptInputs: PromptInput[];
nowPlayingResult: InferenceResult;
paused: boolean;
newResultCallback: (input: InferenceInput, result: InferenceResult) => void;
}
@ -33,7 +31,6 @@ export default function ModelInference({
appState,
promptInputs,
nowPlayingResult,
paused,
newResultCallback,
}: ModelInferenceProps) {
// Create parameters for the inference request
@ -142,10 +139,12 @@ export default function ModelInference({
numInferenceSteps,
seedImageId,
newResultCallback,
numRequestsMade,
numResponsesReceived,
]
);
// Kick off the first inference run when everything is ready.
// Kick off inference requests
useEffect(() => {
// Make sure things are initialized properly
if (
@ -157,8 +156,10 @@ export default function ModelInference({
}
if (numRequestsMade == 0) {
// Kick off the first request
runInference(alpha, seed, appState, promptInputs);
} else if (numRequestsMade == numResponsesReceived) {
// Otherwise buffer ahead a few from where the audio player currently is
// TODO(hayk): Replace this with better buffer management
const nowPlayingCounter = nowPlayingResult ? nowPlayingResult.counter : 0;
@ -170,12 +171,13 @@ export default function ModelInference({
}
}, [
initializedUrlParams,
numRequestsMade,
alpha,
seed,
appState,
promptInputs,
paused,
nowPlayingResult,
numRequestsMade,
numResponsesReceived,
runInference,
]);

14
components/PageHead.tsx Normal file
View File

@ -0,0 +1,14 @@
import Head from "next/head";
export default function PageHead() {
return (
<Head>
<title>Riffusion</title>
<meta
name="description"
content="My name is Riffusion, and I write music."
/>
<link rel="icon" href="/favicon.ico" />
</Head>
);
}

View File

@ -1,9 +1,9 @@
import Head from "next/head";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import * as Tone from "tone";
import AudioPlayer from "../components/AudioPlayer";
import PageHead from "../components/PageHead";
import Info from "../components/Info";
import ModelInference from "../components/ModelInference";
import Pause from "../components/Pause";
@ -156,14 +156,7 @@ export default function Home() {
return (
<>
<Head>
<title>Riffusion</title>
<meta
name="description"
content="My name is Riffusion, and I write music."
/>
<link rel="icon" href="/favicon.ico" />
</Head>
<PageHead />
<div className="bg-[#0A2342] flex flex-row min-h-screen text-white">
<div className="w-1/3 min-h-screen">
@ -179,7 +172,6 @@ export default function Home() {
seed={seed}
appState={appState}
promptInputs={promptInputs}
paused={paused}
nowPlayingResult={nowPlayingResult}
newResultCallback={newResultCallback}
/>