-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update theme, add diarization (#81)
* feat: update theme, add diarization * fix: navigation test * fix: Broken test during to locals change * fix: timeout in navigation test not long enough
- Loading branch information
1 parent
a279685
commit ab8cb00
Showing
32 changed files
with
1,283 additions
and
822 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
AZURE_OPENAI_ENDPOINT=url | ||
AZURE_OPENAI_API_KEY=key | ||
AZURE_OPENAI_GPT_DEPLOYMENT_NAME=name | ||
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=name | ||
AZURE_DOCUMENT_INTELLIGENCE_KEY=key | ||
AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT=endpoint | ||
|
||
OPENAI_API_KEY=key | ||
|
||
AZURE_OPENAI_ENDPOINT=secret | ||
AZURE_OPENAI_API_KEY=secret | ||
AZURE_OPENAI_GPT_DEPLOYMENT_NAME=secret | ||
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=secret | ||
AZURE_OPENAI_WHISPER_DEPLOYMENT_NAME=secret | ||
|
||
AZURE_CREATE_DIARIZATION_ENDPOINT=secret | ||
|
||
AZURE_DOCUMENT_INTELLIGENCE_KEY=secret | ||
AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT=secret | ||
|
||
AWS_ACCESS_KEY=secret | ||
AWS_SECRET_ACCESS_KEY=secret |
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 |
---|---|---|
|
@@ -10,3 +10,4 @@ node_modules | |
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
.vscode | ||
test-results |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,17 @@ function createResolve() { | |
|
||
describe('handle requests', () => { | ||
it('should set request headers and log request information', async () => { | ||
const event = createEvent(); | ||
const event = { | ||
locals: {}, | ||
request: new Request('https://example.com'), | ||
resolve: async () => new Response() | ||
}; | ||
|
||
const resolve = createResolve(); | ||
|
||
const response = await handle({ event, resolve }); | ||
|
||
expect(event.request.headers.get('X-Request-ID')).toBeDefined(); | ||
expect(event.request.headers.get('X-User')).toBe('[email protected]'); | ||
expect(resolve).toHaveBeenCalledWith(event); | ||
expect(response.headers.append).toHaveBeenCalledWith('X-Request-ID', expect.any(String)); | ||
}); | ||
|
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 |
---|---|---|
|
@@ -6,17 +6,16 @@ export async function handle({ event, resolve }) { | |
const requestId = randomUUID(); | ||
const startTime = performance.now(); | ||
|
||
const user = | ||
event.locals.user = | ||
event.request.headers.get('X-MS-CLIENT-PRINCIPAL-NAME') || '[email protected]'; | ||
logger.info({ | ||
type: `Request`, | ||
method: event.request.method, | ||
url: event.request.url, | ||
user, | ||
user: event.locals.user, | ||
requestId | ||
}); | ||
event.request.headers.set('X-Request-ID', requestId); | ||
event.request.headers.set('X-User', user); | ||
|
||
const response = await resolve(event); | ||
|
||
|
@@ -27,7 +26,7 @@ export async function handle({ event, resolve }) { | |
statusCode: response.status, | ||
method: event.request.method, | ||
url: event.request.url, | ||
user, | ||
user: event.locals.user, | ||
requestId, | ||
responseTime | ||
}; | ||
|
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
File renamed without changes.
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,9 @@ | ||
<script lang="ts"> | ||
import BaseBanner from './BaseBanner.svelte'; | ||
</script> | ||
|
||
<BaseBanner | ||
title="Beta Feature" | ||
message="This feature is currently in beta. If you encounter any issues, please contact [email protected]." | ||
variant="warning" | ||
/> |
File renamed without changes.
File renamed without changes.
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 @@ | ||
<i class={`fas fa-download ${$$props.class}`} /> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { AZURE_SPEECH_SERVICES_KEY } from '$lib/server/secrets'; | ||
|
||
type TranscriptionLocationResponse = { | ||
values: { | ||
self: string; | ||
name: string; | ||
kind: 'Transcription' | 'TranscriptionReport'; | ||
properties: { | ||
size: number; | ||
}; | ||
createdDateTime: string; | ||
links: { | ||
contentUrl: string; | ||
}; | ||
}[]; | ||
}; | ||
|
||
export async function GET({ request }) { | ||
const url = request.headers.get('X-Transcript-Url'); | ||
if (url === null) { | ||
return new Response('No valid url.', { status: 400 }); | ||
} | ||
|
||
const transcriptLocationJson: TranscriptionLocationResponse = await ( | ||
await fetch(url, { | ||
headers: { | ||
'Ocp-Apim-Subscription-Key': AZURE_SPEECH_SERVICES_KEY | ||
} | ||
}) | ||
).json(); | ||
|
||
const urls = transcriptLocationJson.values | ||
.filter((json) => json.kind === 'Transcription') | ||
.map((json) => { | ||
return { name: json.name, link: json.links.contentUrl }; | ||
}); | ||
const responses = await Promise.all( | ||
urls.map(async (url) => { | ||
return await fetch(url.link, { | ||
headers: { | ||
'Ocp-Apim-Subscription-Key': AZURE_SPEECH_SERVICES_KEY | ||
} | ||
}); | ||
}) | ||
); | ||
|
||
return new Response(responses[0].body); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { AZURE_SPEECH_SERVICES_ENDPOINT, AZURE_SPEECH_SERVICES_KEY } from '$lib/server/secrets'; | ||
import type { TranscriptionResponse } from './types'; | ||
|
||
export async function load({ fetch, locals }) { | ||
const transcriptions: TranscriptionResponse = await fetch( | ||
AZURE_SPEECH_SERVICES_ENDPOINT + '/speechtotext/v3.2/transcriptions', | ||
{ | ||
headers: { | ||
'Ocp-Apim-Subscription-Key': AZURE_SPEECH_SERVICES_KEY | ||
} | ||
} | ||
).then(async (resp) => await resp.json()); | ||
const userTranscriptions = transcriptions.values | ||
.filter((transcript) => { | ||
// As a bit of a user-management hack, the owner is stored in the display name. | ||
return transcript.displayName.split('-!-')[0] === locals.user; | ||
}) | ||
.map((transcript) => { | ||
transcript.displayName = transcript.displayName.split('-!-')[1] ?? transcript.displayName; | ||
return transcript; | ||
}) | ||
.sort((a, b) => b.createdDateTime.localeCompare(a.createdDateTime)); | ||
return { values: userTranscriptions }; | ||
} |
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,62 @@ | ||
<script lang="ts"> | ||
import BetaBanner from '$lib/components/banners/BetaBanner.svelte'; | ||
import HasBaaBanner from '$lib/components/banners/HasBaaBanner.svelte'; | ||
import { downloadBlob } from '$lib/fileHandling'; | ||
import DownloadIcon from '$lib/icons/DownloadIcon.svelte'; | ||
import type { Transcription, TranscriptionResponse } from './types'; | ||
export let data: TranscriptionResponse; | ||
async function downloadFile(transcription: Transcription) { | ||
const response = await fetch('/api/diarize-retrieve', { | ||
headers: { | ||
'X-Transcript-Url': transcription.links.files | ||
} | ||
}); | ||
const blob = await response.blob(); | ||
const fileparts = transcription.displayName.split('.'); | ||
fileparts.pop(); | ||
const filename = fileparts.join('') + '.json'; | ||
downloadBlob(blob, filename); | ||
} | ||
</script> | ||
|
||
<div class="space-y-2"> | ||
<BetaBanner /> | ||
<HasBaaBanner /> | ||
</div> | ||
<span> | ||
Here you may find the results of your submitted diarizations. Please note that it can take up to a | ||
few hours before your diarizations are completed. Diarization results are deleted after a week. | ||
</span> | ||
|
||
<div class="table-container"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Created at (UTC)</th> | ||
<th>Status</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{#each data.values as transcription} | ||
<tr> | ||
<td>{transcription.displayName}</td> | ||
<td>{transcription.createdDateTime}</td> | ||
<td> | ||
{#if transcription.status === 'Succeeded'} | ||
<button | ||
class="btn btn-sm hover:variant-ghost-primary" | ||
on:click={() => downloadFile(transcription)} | ||
> | ||
<DownloadIcon class="text-lg" /> | ||
</button> | ||
{:else} | ||
{transcription.status} | ||
{/if} | ||
</td> | ||
</tr> | ||
{/each} | ||
</tbody> | ||
</table> | ||
</div> |
Oops, something went wrong.