graphcore-audio 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
audio/__init__.py ADDED
File without changes
audio/apps.py ADDED
@@ -0,0 +1,14 @@
1
+ from graphcore.public.apps import GraphCoreAppConfig
2
+
3
+
4
+ class AudioConfig(GraphCoreAppConfig):
5
+ # Django picks this config for the app package.
6
+ default = True
7
+ name = 'audio'
8
+ # Django app label. Must be unique across the deployment.
9
+ label = 'audio'
10
+ # Stable graphcore identity: namespaces this app's entity type ids and keys
11
+ # its per-user mount folder. Safe to move the package; never change this.
12
+ graphcore_app_id = 'audio'
13
+ graphcore_authorization = 'audio.authorization.configure'
14
+ graphcore_persistence = 'audio.persistence.configure'
audio/authorization.py ADDED
@@ -0,0 +1,13 @@
1
+ """Authorization policy for the audio app: a recording is its
2
+ owner's alone, and anyone signed in may open one of their own."""
3
+ from graphcore.public.auth.perms import Create, Write
4
+ from graphcore.public.auth.policy import AccessPolicy
5
+ from graphcore.public.entities import Deployment
6
+
7
+ from audio.entities.recording import Recording
8
+ from audio.strategies.recordings import OpenRecording, Transcribe
9
+
10
+
11
+ def configure(policy: AccessPolicy) -> None:
12
+ policy.define(Recording, shareable=False, can_contain=[], strategies={Transcribe: Write()})
13
+ policy.extend(Deployment, strategies={OpenRecording: Create()})
audio/conf.py ADDED
@@ -0,0 +1,27 @@
1
+ """The app's settings, read at call time so a test may override them."""
2
+ import os
3
+ from typing import Optional
4
+
5
+ from django.conf import settings
6
+
7
+ DEFAULT_MODEL = 'openai/gpt-4o-mini-transcribe'
8
+ # Base64 in a strategy call adds a third; this keeps the message under the
9
+ # web server's 16 MB WebSocket limit.
10
+ DEFAULT_MAX_AUDIO_BYTES = 8 * 1024 * 1024
11
+
12
+
13
+ def model() -> str:
14
+ return getattr(settings, 'AUDIO_TRANSCRIPTION_MODEL', DEFAULT_MODEL)
15
+
16
+
17
+ def max_audio_bytes() -> int:
18
+ return int(getattr(settings, 'AUDIO_MAX_UPLOAD_BYTES', DEFAULT_MAX_AUDIO_BYTES))
19
+
20
+
21
+ def provider_key(provider: str) -> Optional[str]:
22
+ name = f'{provider.upper()}_API_KEY'
23
+ return getattr(settings, name, None) or os.environ.get(name) or None
24
+
25
+
26
+ def provider_read_timeout() -> float:
27
+ return float(getattr(settings, 'AUDIO_PROVIDER_READ_TIMEOUT', 60))
@@ -0,0 +1,11 @@
1
+ # Entity types for the audio app. Every module in this package is
2
+ # imported at startup, so decorated classes register themselves.
3
+ #
4
+ # from graphcore.public.entities import Entity, register_entity
5
+ #
6
+ # @register_entity()
7
+ # class Board(Entity):
8
+ # pass
9
+ #
10
+ # Registers as 'audio.Board' — namespaced by this app's
11
+ # graphcore_app_id, so it cannot collide with another app's Board.
@@ -0,0 +1,10 @@
1
+ from graphcore.public.entities import Entity, register_entity
2
+
3
+
4
+ @register_entity()
5
+ class Recording(Entity):
6
+ """What one person dictated somewhere: the text of the latest take. The
7
+ audio is never kept."""
8
+ purpose: str = ''
9
+ text: str = ''
10
+ take: int = 0
@@ -0,0 +1,26 @@
1
+ # Generated by Django 5.2.19 on 2026-11-16 13:29
2
+
3
+ import django.db.models.deletion
4
+ from django.db import migrations, models
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+
9
+ initial = True
10
+
11
+ dependencies = [
12
+ ('graphcore', '0003_entity_key'),
13
+ ]
14
+
15
+ operations = [
16
+ migrations.CreateModel(
17
+ name='RecordingModel',
18
+ fields=[
19
+ ('entitymodel_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='graphcore.entitymodel')),
20
+ ('purpose', models.CharField(blank=True, db_index=True, default='', max_length=255)),
21
+ ('text', models.TextField(blank=True, default='')),
22
+ ('take', models.IntegerField(default=0)),
23
+ ],
24
+ bases=('graphcore.entitymodel',),
25
+ ),
26
+ ]
File without changes
audio/models.py ADDED
@@ -0,0 +1,9 @@
1
+ from django.db import models
2
+
3
+ from graphcore.public.persistence.django import EntityModel
4
+
5
+
6
+ class RecordingModel(EntityModel):
7
+ purpose = models.CharField(max_length=255, default='', blank=True, db_index=True)
8
+ text = models.TextField(default='', blank=True)
9
+ take = models.IntegerField(default=0)
audio/persistence.py ADDED
@@ -0,0 +1,6 @@
1
+ from audio.entities.recording import Recording
2
+ from audio.models import RecordingModel
3
+
4
+
5
+ def configure(entities) -> None:
6
+ entities.bind_storage(Recording, RecordingModel)
File without changes
@@ -0,0 +1,35 @@
1
+ """A transcriber that plays scripted texts and records what it was sent."""
2
+ from collections import deque
3
+ from typing import ClassVar, Optional
4
+
5
+ from audio.providers.port import Transcriber
6
+
7
+
8
+ async def scripted_text(model: str, audio: bytes, mime_type: str, language: Optional[str]) -> str | Exception:
9
+ """The next reply a test queued, else 'ok'. Spec tests patch it in the stack's processes."""
10
+ return FakeTranscriber.replies.popleft() if FakeTranscriber.replies else 'ok'
11
+
12
+
13
+ class FakeTranscriber(Transcriber):
14
+ name = 'fake'
15
+ needs_key = False
16
+
17
+ replies: ClassVar[deque] = deque()
18
+ requests: ClassVar[list[dict]] = []
19
+
20
+ @classmethod
21
+ def reset(cls) -> None:
22
+ cls.replies.clear()
23
+ cls.requests.clear()
24
+
25
+ @classmethod
26
+ def play(cls, *replies) -> None:
27
+ """Queue one reply per call: a text, or an exception to raise."""
28
+ cls.replies.extend(replies)
29
+
30
+ async def transcribe(self, model: str, audio: bytes, mime_type: str, language: Optional[str] = None) -> str:
31
+ self.requests.append({'model': model, 'audio': audio, 'mime_type': mime_type, 'language': language})
32
+ reply = await scripted_text(model, audio, mime_type, language)
33
+ if isinstance(reply, Exception):
34
+ raise reply
35
+ return reply
@@ -0,0 +1,50 @@
1
+ """OpenAI's transcription endpoint behind the port."""
2
+ from typing import Optional
3
+
4
+ import openai
5
+
6
+ from audio.providers.port import ProviderError, Transcriber
7
+
8
+ _EXTENSIONS = {
9
+ 'audio/webm': 'webm', 'audio/mp4': 'mp4', 'audio/ogg': 'ogg', 'audio/wav': 'wav',
10
+ 'audio/x-wav': 'wav', 'audio/mpeg': 'mp3', 'audio/flac': 'flac', 'audio/x-m4a': 'm4a',
11
+ }
12
+
13
+
14
+ class OpenAITranscriber(Transcriber):
15
+ name = 'openai'
16
+
17
+ def __init__(self, api_key: Optional[str], read_timeout: float, http_client=None):
18
+ super().__init__(api_key, read_timeout)
19
+ # Retries are the executor's.
20
+ self._client = openai.AsyncOpenAI(
21
+ api_key=api_key, max_retries=0, http_client=http_client,
22
+ timeout=openai.Timeout(read_timeout, connect=10.0),
23
+ )
24
+
25
+ async def transcribe(self, model: str, audio: bytes, mime_type: str, language: Optional[str] = None) -> str:
26
+ # The endpoint tells the format from the file name.
27
+ extension = _EXTENSIONS.get(mime_type.partition(';')[0].strip().lower())
28
+ if extension is None:
29
+ raise ProviderError('unsupported_audio', f"Cannot transcribe {mime_type or 'audio of an unknown type'}",
30
+ retryable=False)
31
+ params = {'model': model, 'file': (f'audio.{extension}', audio, mime_type), 'response_format': 'json'}
32
+ if language:
33
+ params['language'] = language
34
+ try:
35
+ result = await self._client.audio.transcriptions.create(**params)
36
+ except openai.APIError as exc:
37
+ raise _provider_error(exc) from exc
38
+ return result.text.strip()
39
+
40
+
41
+ def _provider_error(exc: openai.APIError) -> ProviderError:
42
+ if isinstance(exc, (openai.APITimeoutError, openai.APIConnectionError)):
43
+ return ProviderError('unreachable', str(exc), retryable=True)
44
+ if isinstance(exc, openai.RateLimitError):
45
+ return ProviderError('rate_limit', exc.message, retryable=True)
46
+ if isinstance(exc, openai.InternalServerError):
47
+ return ProviderError('server_error', exc.message, retryable=True)
48
+ if isinstance(exc, (openai.AuthenticationError, openai.PermissionDeniedError)):
49
+ return ProviderError('auth', exc.message, retryable=False)
50
+ return ProviderError('bad_request', exc.message, retryable=False)
@@ -0,0 +1,31 @@
1
+ """What the app needs from a speech-to-text vendor."""
2
+ from abc import ABC, abstractmethod
3
+ from typing import Optional
4
+
5
+
6
+ class ProviderError(Exception):
7
+ def __init__(self, code: str, message: str, *, retryable: bool):
8
+ super().__init__(f"{code}: {message}")
9
+ self.code = code
10
+ self.message = message
11
+ self.retryable = retryable
12
+
13
+ def __reduce__(self):
14
+ return _provider_error, (type(self), self.code, self.message, self.retryable)
15
+
16
+
17
+ def _provider_error(cls, code: str, message: str, retryable: bool) -> 'ProviderError':
18
+ return cls(code, message, retryable=retryable)
19
+
20
+
21
+ class Transcriber(ABC):
22
+ name: str
23
+ needs_key = True
24
+
25
+ def __init__(self, api_key: Optional[str], read_timeout: float):
26
+ self.api_key = api_key
27
+ self.read_timeout = read_timeout
28
+
29
+ @abstractmethod
30
+ async def transcribe(self, model: str, audio: bytes, mime_type: str, language: Optional[str] = None) -> str:
31
+ """The words spoken in `audio`. `language` is an ISO-639-1 hint."""
@@ -0,0 +1,31 @@
1
+ from importlib import import_module
2
+
3
+ from audio import conf
4
+ from audio.providers.port import ProviderError, Transcriber
5
+
6
+ _ADAPTERS = {
7
+ 'fake': 'audio.providers.fake.FakeTranscriber',
8
+ 'openai': 'audio.providers.openai.OpenAITranscriber',
9
+ }
10
+ _built: dict[str, Transcriber] = {}
11
+
12
+
13
+ def transcriber_for(model_id: str) -> tuple[Transcriber, str]:
14
+ """The transcriber serving `model_id`, built once per process, and the
15
+ model name to send it."""
16
+ name, _, model = model_id.partition('/')
17
+ if name not in _built:
18
+ path = _ADAPTERS.get(name)
19
+ if path is None:
20
+ raise ProviderError('unknown_model', f"No transcription provider named {name!r}", retryable=False)
21
+ module, _, cls_name = path.rpartition('.')
22
+ transcriber_cls = getattr(import_module(module), cls_name)
23
+ key = conf.provider_key(name)
24
+ if transcriber_cls.needs_key and not key:
25
+ raise ProviderError('no_key', f"{name.upper()}_API_KEY is not set", retryable=False)
26
+ _built[name] = transcriber_cls(key, conf.provider_read_timeout())
27
+ return _built[name], model
28
+
29
+
30
+ def reset() -> None:
31
+ _built.clear()
@@ -0,0 +1,3 @@
1
+ """Spec tests for the audio app: dictation as its clients see it, on a live
2
+ stack with the speech-to-text vendor's replies decided by each scenario.
3
+ Run with `scripts/test --specs audio`."""
audio/specs/dsl.py ADDED
@@ -0,0 +1,120 @@
1
+ """The audio app's vocabulary: people open a recording for a purpose,
2
+ dictate takes into it, and read back the words. The only module that names
3
+ the app's strategies, types and the vendor seam."""
4
+ from __future__ import annotations
5
+
6
+ import base64
7
+ from dataclasses import dataclass
8
+ from typing import Optional
9
+
10
+ from graphcore.public.live_testing import Actor, Dsl, HttpError, strategy
11
+
12
+ from audio.providers.port import ProviderError
13
+
14
+ RECORDING = 'audio.Recording'
15
+ TRANSCRIPTION_MODEL = 'audio.conf.model'
16
+ MAX_AUDIO_BYTES = 'audio.conf.max_audio_bytes'
17
+ VENDOR = 'audio.providers.fake.scripted_text'
18
+ SCRIPTED_MODEL = 'fake/scribe'
19
+ SPEECH = b'RIFF....WAVEfmt speech'
20
+
21
+
22
+ @dataclass
23
+ class Take:
24
+ """What a person was told about one dictated take."""
25
+ status: str
26
+ request_id: Optional[str]
27
+ text: Optional[str] = None
28
+ take: Optional[int] = None
29
+ error: Optional[str] = None
30
+
31
+ @property
32
+ def succeeded(self) -> bool:
33
+ return self.status == 'succeeded'
34
+
35
+
36
+ def _take(outcome: dict) -> Take:
37
+ ret = outcome.get('ret_val') or {}
38
+ return Take(outcome['status'], outcome.get('strategy_request_id'), ret.get('text'), ret.get('take'),
39
+ outcome.get('error'))
40
+
41
+
42
+ class Speaker(Actor):
43
+ async def opens_a_recording(self, purpose: str = 'notes.editor') -> str:
44
+ outcome = await self.execute_one(strategy('OpenRecording', purpose=purpose))
45
+ assert outcome['status'] == 'succeeded', outcome
46
+ return outcome['ret_val']['recording_id']
47
+
48
+ async def dictates(self, recording: str, audio: bytes = SPEECH, mime_type: str = 'audio/webm',
49
+ language: Optional[str] = None, wait: bool = True) -> Take:
50
+ params = {'audio': base64.b64encode(audio).decode(), 'mime_type': mime_type}
51
+ if language:
52
+ params['language'] = language
53
+ return _take(await self.execute_one(strategy('Transcribe', recording, **params), wait=wait))
54
+
55
+ async def sends_text_as_audio(self, recording: str, text: str) -> Take:
56
+ return _take(await self.execute_one(strategy('Transcribe', recording, audio=text, mime_type='audio/webm')))
57
+
58
+ async def shares(self, recording: str, with_: 'Speaker') -> dict:
59
+ return await self.execute_one(strategy('CreateGrant', recording, subject_id=await with_.entity_id(),
60
+ role_name='viewer'))
61
+
62
+ async def words_in(self, recording: str) -> str:
63
+ return (await self.get(recording))['text']
64
+
65
+ async def takes_of(self, recording: str) -> int:
66
+ return (await self.get(recording))['take']
67
+
68
+ async def can_read(self, recording: str) -> bool:
69
+ try:
70
+ await self.get(recording)
71
+ return True
72
+ except HttpError:
73
+ return False
74
+
75
+ async def recordings(self) -> list[dict]:
76
+ return await self.find(RECORDING)
77
+
78
+ async def finished(self, take: Take) -> Take:
79
+ request = await super().finished(take.request_id)
80
+ return _take({**request, 'strategy_request_id': take.request_id})
81
+
82
+ async def request(self, take: Take) -> dict:
83
+ return await self.get(take.request_id)
84
+
85
+ async def opens_over_mcp(self, recording: str) -> str:
86
+ result = await self.mcp_tool('open', at=recording)
87
+ return result['content'][0]['text']
88
+
89
+
90
+ class AudioDsl(Dsl):
91
+ actor_class = Speaker
92
+
93
+ def as_(self, name: str) -> Speaker:
94
+ return super().as_(name)
95
+
96
+ def _on_the_scripted_model(self) -> None:
97
+ if not getattr(self, '_scripted', False):
98
+ self._scripted = True
99
+ self.patch(TRANSCRIPTION_MODEL, return_value=SCRIPTED_MODEL).start()
100
+
101
+ def the_vendor_hears(self, *texts: str, hold: bool = False):
102
+ """Each transcription in turn answers with the next text."""
103
+ self._on_the_scripted_model()
104
+ return self.patch(VENDOR, side_effect=list(texts), hold=hold)
105
+
106
+ def the_vendor_fails(self, code: str, message: str, retryable: bool = False):
107
+ self._on_the_scripted_model()
108
+ return self.patch(VENDOR, side_effect=ProviderError(code, message, retryable=retryable))
109
+
110
+ def the_vendor_is_busy_once_then_hears(self, text: str):
111
+ self._on_the_scripted_model()
112
+ return self.patch(VENDOR, side_effect=[ProviderError('overloaded', 'try again', retryable=True), text])
113
+
114
+ def uploads_are_limited_to(self, size: int):
115
+ return self.patch(MAX_AUDIO_BYTES, return_value=size)
116
+
117
+
118
+ def heard(vendor) -> list[dict]:
119
+ """What the vendor was sent, one entry per call."""
120
+ return [dict(zip(('model', 'audio', 'mime_type', 'language'), call.args)) for call in vendor.call_args_list]
@@ -0,0 +1,20 @@
1
+ """The same recording through an agent connected over MCP."""
2
+ from __future__ import annotations
3
+
4
+ from graphcore.public.live_testing import scenario
5
+
6
+ from audio.specs.dsl import AudioDsl
7
+
8
+
9
+ @scenario('Clients', 'An agent over MCP reads the words of a recording, and only its owner\'s')
10
+ async def _(a: AudioDsl):
11
+ ana, ben = a.as_('Ana'), a.as_('Ben')
12
+ recording = await ana.opens_a_recording('notes.editor')
13
+ with a.the_vendor_hears('Call the florist.'):
14
+ await ana.dictates(recording)
15
+
16
+ place = await ana.opens_over_mcp(recording)
17
+ refused = await ben.opens_over_mcp(recording)
18
+
19
+ assert 'Call the florist.' in place and 'take 1' in place, place
20
+ assert 'Call the florist.' not in refused, refused
@@ -0,0 +1,87 @@
1
+ """Dictating into a recording: each take's words become the recording's text."""
2
+ from __future__ import annotations
3
+
4
+ from graphcore.public.live_testing import scenario
5
+
6
+ from audio.specs.dsl import SCRIPTED_MODEL, AudioDsl, heard
7
+
8
+
9
+ @scenario('Recordings', 'A person has one recording per purpose, the same one every time they open it')
10
+ async def _(a: AudioDsl):
11
+ ana = a.as_('Ana')
12
+
13
+ composer = await ana.opens_a_recording('agents.composer')
14
+ again = await ana.opens_a_recording('agents.composer')
15
+ notes = await ana.opens_a_recording('notes.editor')
16
+
17
+ assert composer == again and composer != notes
18
+ assert await ana.words_in(composer) == '' and await ana.takes_of(composer) == 0
19
+ assert sorted(r['purpose'] for r in await ana.recordings()) == ['agents.composer', 'notes.editor']
20
+
21
+
22
+ @scenario('Recordings', "Two people opening the same purpose get recordings of their own")
23
+ async def _(a: AudioDsl):
24
+ ana, ben = a.as_('Ana'), a.as_('Ben')
25
+
26
+ hers = await ana.opens_a_recording('agents.composer')
27
+ his = await ben.opens_a_recording('agents.composer')
28
+
29
+ assert hers != his
30
+ assert [r['entity_id'] for r in await ben.recordings()] == [his]
31
+
32
+
33
+ @scenario('Dictation', 'The words of a take become the recording\'s text, and the take is counted')
34
+ async def _(a: AudioDsl):
35
+ ana = a.as_('Ana')
36
+ recording = await ana.opens_a_recording()
37
+
38
+ with a.the_vendor_hears('Book the venue for June.') as vendor:
39
+ take = await ana.dictates(recording, mime_type='audio/webm', language='en')
40
+
41
+ assert take.succeeded and (take.text, take.take) == ('Book the venue for June.', 1), take
42
+ assert await ana.words_in(recording) == 'Book the venue for June.'
43
+ assert heard(vendor) == [{'model': SCRIPTED_MODEL.split('/')[1], 'audio': b'RIFF....WAVEfmt speech',
44
+ 'mime_type': 'audio/webm', 'language': 'en'}]
45
+
46
+
47
+ @scenario('Dictation', 'A second take replaces the text and counts two')
48
+ async def _(a: AudioDsl):
49
+ ana = a.as_('Ana')
50
+ recording = await ana.opens_a_recording()
51
+
52
+ with a.the_vendor_hears('First thought.', 'Second thought.'):
53
+ await ana.dictates(recording)
54
+ take = await ana.dictates(recording)
55
+
56
+ assert (take.text, take.take) == ('Second thought.', 2), take
57
+ assert (await ana.words_in(recording), await ana.takes_of(recording)) == ('Second thought.', 2)
58
+
59
+
60
+ @scenario('Dictation', 'A watcher sees the words arrive over the live connection')
61
+ async def _(a: AudioDsl):
62
+ ana = a.as_('Ana')
63
+ recording = await ana.opens_a_recording()
64
+ connection = await ana.connects()
65
+ await connection.subscribe(recording)
66
+
67
+ with a.the_vendor_hears('Live words.'):
68
+ await ana.dictates(recording)
69
+
70
+ await connection.sees(recording, text='Live words.', take=1)
71
+
72
+
73
+ @scenario('Dictation', 'A take nobody waits for still lands, once the vendor answers')
74
+ async def _(a: AudioDsl):
75
+ ana = a.as_('Ana')
76
+ recording = await ana.opens_a_recording()
77
+
78
+ with a.the_vendor_hears('Slowly spoken.', hold=True) as vendor:
79
+ take = await ana.dictates(recording, wait=False)
80
+ await vendor.wait_for_calls(1)
81
+ assert (await ana.request(take))['status'] == 'running'
82
+ assert await ana.takes_of(recording) == 0
83
+
84
+ vendor.release()
85
+
86
+ assert (await ana.finished(take)).succeeded
87
+ assert await ana.words_in(recording) == 'Slowly spoken.'
@@ -0,0 +1,45 @@
1
+ """A recording is its owner's alone, and the audio is never kept."""
2
+ from __future__ import annotations
3
+
4
+ from graphcore.public.live_testing import scenario
5
+
6
+ from audio.specs.dsl import AudioDsl
7
+
8
+
9
+ @scenario('Privacy', "Nobody else can read a person's recording or dictate into it")
10
+ async def _(a: AudioDsl):
11
+ ana, ben = a.as_('Ana'), a.as_('Ben')
12
+ recording = await ana.opens_a_recording()
13
+ with a.the_vendor_hears('Private words.', 'Not mine.') as vendor:
14
+ await ana.dictates(recording)
15
+
16
+ take = await ben.dictates(recording)
17
+
18
+ assert not take.succeeded, take
19
+ assert not await ben.can_read(recording)
20
+ assert await ana.words_in(recording) == 'Private words.'
21
+ assert vendor.call_count == 1
22
+
23
+
24
+ @scenario('Privacy', 'A recording cannot be shared')
25
+ async def _(a: AudioDsl):
26
+ ana, ben = a.as_('Ana'), a.as_('Ben')
27
+ recording = await ana.opens_a_recording()
28
+
29
+ outcome = await ana.shares(recording, with_=ben)
30
+
31
+ assert outcome['status'] == 'failed', outcome
32
+ assert not await ben.can_read(recording)
33
+
34
+
35
+ @scenario('Privacy', 'The audio is not kept on the request once the take ends')
36
+ async def _(a: AudioDsl):
37
+ ana = a.as_('Ana')
38
+ recording = await ana.opens_a_recording()
39
+
40
+ with a.the_vendor_hears('Gone afterwards.'):
41
+ take = await ana.dictates(recording)
42
+
43
+ params = (await ana.request(take))['param_config']
44
+ assert params['mime_type'] == 'audio/webm'
45
+ assert 'UklGRi4uLi5XQVZFZm10IHNwZWVjaA' not in str(params), params
@@ -0,0 +1,59 @@
1
+ """What a person is told when the speech-to-text vendor, or the audio, is not right."""
2
+ from __future__ import annotations
3
+
4
+ from graphcore.public.live_testing import scenario
5
+
6
+ from audio.specs.dsl import AudioDsl
7
+
8
+
9
+ @scenario('Vendor', "Without the vendor's key, a take fails naming the key and leaves the text alone")
10
+ async def _(a: AudioDsl):
11
+ ana = a.as_('Ana')
12
+ recording = await ana.opens_a_recording()
13
+
14
+ take = await ana.dictates(recording)
15
+
16
+ assert take.status == 'failed' and 'OPENAI_API_KEY' in take.error, take
17
+ assert (await ana.words_in(recording), await ana.takes_of(recording)) == ('', 0)
18
+
19
+
20
+ @scenario('Vendor', 'A vendor that refuses the audio fails the take and writes nothing')
21
+ async def _(a: AudioDsl):
22
+ ana = a.as_('Ana')
23
+ recording = await ana.opens_a_recording()
24
+
25
+ with a.the_vendor_fails('invalid_request', 'unsupported audio format'):
26
+ take = await ana.dictates(recording)
27
+
28
+ assert take.status == 'failed' and 'unsupported audio format' in take.error, take
29
+ assert await ana.takes_of(recording) == 0
30
+
31
+
32
+ @scenario('Vendor', 'A busy vendor is asked again, and the second answer is kept')
33
+ async def _(a: AudioDsl):
34
+ ana = a.as_('Ana')
35
+ recording = await ana.opens_a_recording()
36
+
37
+ with a.the_vendor_is_busy_once_then_hears('Second time lucky.') as vendor:
38
+ take = await ana.dictates(recording)
39
+
40
+ assert take.succeeded, take
41
+ assert vendor.call_count == 2
42
+ assert (await ana.words_in(recording), await ana.takes_of(recording)) == ('Second time lucky.', 1)
43
+
44
+
45
+ @scenario('Limits', 'Audio that is not base64, empty, or too large is refused before the vendor hears it')
46
+ async def _(a: AudioDsl):
47
+ ana = a.as_('Ana')
48
+ recording = await ana.opens_a_recording()
49
+
50
+ with a.the_vendor_hears('never') as vendor, a.uploads_are_limited_to(8):
51
+ garbled = await ana.sends_text_as_audio(recording, 'not base64!')
52
+ empty = await ana.dictates(recording, audio=b'')
53
+ large = await ana.dictates(recording, audio=b'123456789')
54
+
55
+ assert 'not base64' in garbled.error, garbled
56
+ assert 'empty' in empty.error, empty
57
+ assert 'larger than 8 bytes' in large.error, large
58
+ assert vendor.call_count == 0
59
+ assert await ana.takes_of(recording) == 0
@@ -0,0 +1,11 @@
1
+ # Strategies for the audio app. Every module in this package is
2
+ # imported at startup, so decorated classes register themselves.
3
+ #
4
+ # from graphcore.public.strategies import Strategy, register_strategy
5
+ #
6
+ # from audio.entities.board import Board
7
+ #
8
+ # @register_strategy(Board)
9
+ # class ArchiveBoard(Strategy):
10
+ # async def apply(self):
11
+ # return self.strategy_request, self.entity
@@ -0,0 +1,88 @@
1
+ import base64
2
+ import binascii
3
+ from typing import Optional
4
+
5
+ from graphcore.public.entities import Entity
6
+ from graphcore.public.errors import InvalidRequest, StrategyFailed, TransientError
7
+ from graphcore.public.persistence import AllOf, EntityFilter, Equal
8
+ from graphcore.public.strategies import Strategy, StrategyRequestPayload, register_strategy
9
+
10
+ from audio import conf
11
+ from audio.entities.recording import Recording
12
+ from audio.providers.port import ProviderError
13
+ from audio.providers.registry import transcriber_for
14
+
15
+
16
+ def _params(properties: dict, required: tuple = ()) -> dict:
17
+ return {"type": "object", "properties": properties, "required": list(required), "additionalProperties": False}
18
+
19
+
20
+ @register_strategy(Entity)
21
+ class OpenRecording(Strategy):
22
+ strategy_description = "Returns the caller's recording for a purpose, creating it the first time"
23
+ param_schema = _params(
24
+ {"purpose": {"type": "string", "description": "Where the dictation goes, such as `agents.composer`"}},
25
+ required=('purpose',),
26
+ )
27
+
28
+ async def apply(self) -> tuple:
29
+ purpose = self.strategy_request.param_config['purpose']
30
+ # The first in listing order, so a duplicate left by a lost race never takes over.
31
+ page = await self.session.list(EntityFilter(
32
+ type_ids=frozenset({Recording.get_entity_type_id()}),
33
+ where=AllOf((Equal('owner', self.principal_entity_id), Equal('purpose', purpose))),
34
+ ), limit=1)
35
+ recording = page.entities[0] if page.entities else await self.save_entity(
36
+ self.session.create(Recording, purpose=purpose),
37
+ )
38
+ self.strategy_request.ret_val['recording_id'] = recording.entity_id
39
+ return self.strategy_request, self.entity
40
+
41
+ @classmethod
42
+ def request_constructor(cls, purpose: str) -> StrategyRequestPayload:
43
+ return cls._build_request(target_entity_id=None, param_config={'purpose': purpose})
44
+
45
+
46
+ @register_strategy(Recording)
47
+ class Transcribe(Strategy):
48
+ strategy_description = "Turns recorded speech into the recording's text and counts a new take"
49
+ timeout = 120
50
+ transient_params = frozenset({'audio'})
51
+ param_schema = _params(
52
+ {
53
+ "audio": {"type": "string", "description": "The audio file, base64-encoded"},
54
+ "mime_type": {"type": "string", "description": "The audio's type, such as `audio/webm`"},
55
+ "language": {"type": "string", "description": "ISO-639-1 code of the spoken language, when known"},
56
+ },
57
+ required=('audio', 'mime_type'),
58
+ )
59
+
60
+ async def apply(self) -> tuple:
61
+ given = self.strategy_request.param_config
62
+ try:
63
+ audio = base64.b64decode(given['audio'], validate=True)
64
+ except (binascii.Error, ValueError) as exc:
65
+ raise InvalidRequest("audio is not base64") from exc
66
+ if not audio:
67
+ raise InvalidRequest("audio is empty")
68
+ if len(audio) > conf.max_audio_bytes():
69
+ raise InvalidRequest(f"audio is larger than {conf.max_audio_bytes()} bytes")
70
+ try:
71
+ transcriber, model = transcriber_for(conf.model())
72
+ text = await transcriber.transcribe(model, audio, given['mime_type'], given.get('language'))
73
+ except ProviderError as exc:
74
+ if exc.retryable:
75
+ raise TransientError(str(exc)) from exc
76
+ raise StrategyFailed(str(exc)) from exc
77
+ self.entity.text = text
78
+ self.entity.take += 1
79
+ self.strategy_request.ret_val.update(text=text, take=self.entity.take)
80
+ return self.strategy_request, self.entity
81
+
82
+ @classmethod
83
+ def request_constructor(cls, target_entity_id: str, audio: str, mime_type: str,
84
+ language: Optional[str] = None) -> StrategyRequestPayload:
85
+ param_config = {'audio': audio, 'mime_type': mime_type}
86
+ if language:
87
+ param_config['language'] = language
88
+ return cls._build_request(target_entity_id=target_entity_id, param_config=param_config)
audio/test_settings.py ADDED
@@ -0,0 +1,6 @@
1
+ # Runs this app's tests without a project:
2
+ # python -m django test audio --settings=audio.test_settings
3
+ # Inside a project, `graphcore test` runs them with the project's settings.
4
+ from graphcore.public.test_settings import app_test_settings
5
+
6
+ globals().update(app_test_settings('audio'))
File without changes
@@ -0,0 +1,65 @@
1
+ """The OpenAI adapter against the SDK itself, with the HTTP transport replaced."""
2
+ import httpx
3
+ from django.test import SimpleTestCase
4
+ from openai import DefaultAsyncHttpxClient
5
+
6
+ from audio.providers.openai import OpenAITranscriber
7
+ from audio.providers.port import ProviderError
8
+
9
+
10
+ def transcriber(handler) -> OpenAITranscriber:
11
+ client = DefaultAsyncHttpxClient(transport=httpx.MockTransport(handler))
12
+ return OpenAITranscriber('sk-test', 5, http_client=client)
13
+
14
+
15
+ def error(status: int, code: str, message: str = 'No.') -> httpx.Response:
16
+ return httpx.Response(status, json={"error": {"message": message, "type": code, "code": code}})
17
+
18
+
19
+ class OpenAITranscriberTests(SimpleTestCase):
20
+ async def test_the_audio_is_uploaded_as_a_named_file_and_the_text_returned(self):
21
+ sent = {}
22
+
23
+ def handler(request: httpx.Request) -> httpx.Response:
24
+ sent.update(url=str(request.url), body=request.content, auth=request.headers['authorization'])
25
+ return httpx.Response(200, json={"text": " Book the venue.\n"})
26
+
27
+ text = await transcriber(handler).transcribe('gpt-4o-mini-transcribe', b'AUDIO', 'audio/webm;codecs=opus', 'en')
28
+
29
+ self.assertEqual(text, 'Book the venue.')
30
+ self.assertEqual(sent['url'], 'https://api.openai.com/v1/audio/transcriptions')
31
+ self.assertEqual(sent['auth'], 'Bearer sk-test')
32
+ for part in (b'filename="audio.webm"', b'AUDIO', b'gpt-4o-mini-transcribe', b'name="language"\r\n\r\nen'):
33
+ self.assertIn(part, sent['body'])
34
+
35
+ async def test_an_unknown_audio_type_is_refused_before_any_call(self):
36
+ def handler(request):
37
+ raise AssertionError('called the vendor')
38
+
39
+ with self.assertRaises(ProviderError) as caught:
40
+ await transcriber(handler).transcribe('gpt-4o-mini-transcribe', b'AUDIO', 'video/quicktime')
41
+
42
+ self.assertEqual((caught.exception.code, caught.exception.retryable), ('unsupported_audio', False))
43
+
44
+ async def test_each_vendor_error_becomes_its_code(self):
45
+ cases = [
46
+ (error(429, 'rate_limit_exceeded'), 'rate_limit', True),
47
+ (error(500, 'server_error'), 'server_error', True),
48
+ (error(401, 'invalid_api_key'), 'auth', False),
49
+ (error(400, 'invalid_request_error'), 'bad_request', False),
50
+ ]
51
+ for response, code, retryable in cases:
52
+ with self.subTest(code=code), self.assertRaises(ProviderError) as caught:
53
+ await transcriber(lambda request, response=response: response).transcribe(
54
+ 'gpt-4o-mini-transcribe', b'AUDIO', 'audio/webm',
55
+ )
56
+ self.assertEqual((caught.exception.code, caught.exception.retryable), (code, retryable))
57
+
58
+ async def test_an_unreachable_vendor_is_retryable(self):
59
+ def handler(request):
60
+ raise httpx.ConnectError('down')
61
+
62
+ with self.assertRaises(ProviderError) as caught:
63
+ await transcriber(handler).transcribe('gpt-4o-mini-transcribe', b'AUDIO', 'audio/webm')
64
+
65
+ self.assertEqual((caught.exception.code, caught.exception.retryable), ('unreachable', True))
@@ -0,0 +1,139 @@
1
+ import base64
2
+
3
+ from django.test import override_settings
4
+
5
+ from graphcore.public.errors import Forbidden, InvalidRequest, StrategyFailed
6
+ from graphcore.public.testing import GraphCoreTestCase
7
+
8
+ from audio.entities.recording import Recording
9
+ from audio.providers import registry
10
+ from audio.providers.fake import FakeTranscriber
11
+ from audio.providers.port import ProviderError
12
+ from audio.strategies.recordings import OpenRecording, Transcribe
13
+
14
+ AUDIO = b'\x1aE\xdf\xa3 spoken words'
15
+ ENCODED = base64.b64encode(AUDIO).decode()
16
+
17
+
18
+ @override_settings(AUDIO_TRANSCRIPTION_MODEL='fake/listener')
19
+ class RecordingTestCase(GraphCoreTestCase):
20
+ def setUp(self):
21
+ super().setUp()
22
+ FakeTranscriber.reset()
23
+ registry.reset()
24
+
25
+ async def open(self, principal, purpose='agents.composer'):
26
+ completed = await self.run_strategy(principal, OpenRecording.request_constructor(purpose))
27
+ return completed.ret_val['recording_id']
28
+
29
+ async def transcribe(self, principal, recording_id, audio=ENCODED, mime_type='audio/webm', **fields):
30
+ return await self.run_strategy(
31
+ principal, Transcribe.request_constructor(recording_id, audio=audio, mime_type=mime_type, **fields),
32
+ )
33
+
34
+
35
+ class OpenRecordingTests(RecordingTestCase):
36
+ async def test_a_recording_is_top_level_and_owned_by_who_opened_it(self):
37
+ carl = await self.create_user('carl')
38
+
39
+ recording = await self.get_entity(carl, await self.open(carl))
40
+
41
+ self.assertIsInstance(recording, Recording)
42
+ self.assertEqual((recording.parent_id, recording.owner), (None, carl.principal_entity_id))
43
+ self.assertEqual((recording.purpose, recording.text, recording.take), ('agents.composer', '', 0))
44
+
45
+ async def test_opening_again_returns_the_same_recording_for_that_person_and_purpose(self):
46
+ carl = await self.create_user('carl')
47
+ dana = await self.create_user('dana')
48
+ first = await self.open(carl)
49
+
50
+ self.assertEqual(await self.open(carl), first)
51
+ self.assertNotEqual(await self.open(carl, purpose='notes.editor'), first)
52
+ self.assertNotEqual(await self.open(dana), first)
53
+
54
+
55
+ class TranscribeTests(RecordingTestCase):
56
+ async def test_the_spoken_words_become_the_text_and_a_new_take(self):
57
+ carl = await self.create_user('carl')
58
+ recording_id = await self.open(carl)
59
+ FakeTranscriber.play('Book the venue.', 'Then call the florist.')
60
+
61
+ first = await self.transcribe(carl, recording_id, language='en')
62
+ await self.transcribe(carl, recording_id, mime_type='audio/mp4')
63
+
64
+ self.assertEqual(first.ret_val, {'text': 'Book the venue.', 'take': 1})
65
+ recording = await self.get_entity(carl, recording_id)
66
+ self.assertEqual((recording.text, recording.take), ('Then call the florist.', 2))
67
+ self.assertEqual(FakeTranscriber.requests, [
68
+ {'model': 'listener', 'audio': AUDIO, 'mime_type': 'audio/webm', 'language': 'en'},
69
+ {'model': 'listener', 'audio': AUDIO, 'mime_type': 'audio/mp4', 'language': None},
70
+ ])
71
+
72
+ async def test_the_finished_request_does_not_keep_the_audio(self):
73
+ carl = await self.create_user('carl')
74
+
75
+ completed = await self.transcribe(carl, await self.open(carl))
76
+
77
+ self.assertEqual(completed.param_config['audio'], {'redacted': True, 'bytes': len(ENCODED)})
78
+ self.assertEqual(completed.param_config['mime_type'], 'audio/webm')
79
+
80
+ @override_settings(AUDIO_MAX_UPLOAD_BYTES=8)
81
+ async def test_audio_that_is_not_base64_or_empty_or_too_large_is_refused(self):
82
+ carl = await self.create_user('carl')
83
+ recording_id = await self.open(carl)
84
+
85
+ for audio in ('not base64!', '', ENCODED):
86
+ with self.subTest(audio=audio), self.assertRaises(InvalidRequest):
87
+ await self.transcribe(carl, recording_id, audio=audio)
88
+ self.assertEqual(FakeTranscriber.requests, [])
89
+
90
+ async def test_a_provider_failure_fails_the_run_and_leaves_the_recording(self):
91
+ carl = await self.create_user('carl')
92
+ recording_id = await self.open(carl)
93
+ FakeTranscriber.play(ProviderError('bad_request', 'Audio too short', retryable=False))
94
+
95
+ with self.assertRaisesRegex(StrategyFailed, 'bad_request: Audio too short'):
96
+ await self.transcribe(carl, recording_id)
97
+
98
+ recording = await self.get_entity(carl, recording_id)
99
+ self.assertEqual((recording.text, recording.take), ('', 0))
100
+
101
+ async def test_a_retryable_provider_failure_is_tried_again(self):
102
+ carl = await self.create_user('carl')
103
+ recording_id = await self.open(carl)
104
+ FakeTranscriber.play(ProviderError('rate_limit', 'Slow down', retryable=True), 'Second time lucky.')
105
+
106
+ completed = await self.transcribe(carl, recording_id)
107
+
108
+ self.assertEqual(completed.ret_val, {'text': 'Second time lucky.', 'take': 1})
109
+ self.assertEqual(len(FakeTranscriber.requests), 2)
110
+
111
+ @override_settings(AUDIO_TRANSCRIPTION_MODEL='openai/gpt-4o-mini-transcribe', OPENAI_API_KEY='')
112
+ async def test_a_missing_provider_key_is_named(self):
113
+ carl = await self.create_user('carl')
114
+ recording_id = await self.open(carl)
115
+
116
+ with self.assertRaisesRegex(StrategyFailed, 'OPENAI_API_KEY is not set'):
117
+ await self.transcribe(carl, recording_id)
118
+
119
+ async def test_a_recording_is_its_owners_alone(self):
120
+ carl = await self.create_user('carl')
121
+ dana = await self.create_user('dana')
122
+ recording_id = await self.open(carl)
123
+
124
+ with self.assertRaises(Forbidden):
125
+ await self.transcribe(dana, recording_id)
126
+ self.assertNotIsInstance(await self.get_entity(dana, recording_id), Recording)
127
+
128
+
129
+ class AgentViewTests(RecordingTestCase):
130
+ async def test_a_recording_reads_as_its_latest_text(self):
131
+ carl = await self.create_user('carl')
132
+ recording_id = await self.open(carl)
133
+ FakeTranscriber.play('Book the venue.')
134
+ await self.transcribe(carl, recording_id)
135
+
136
+ place = await self.open_place(carl, recording_id)
137
+
138
+ self.assertIn('Dictation for `agents.composer`, take 1.', place.text)
139
+ self.assertIn('Book the venue.', place.text)
@@ -0,0 +1,3 @@
1
+ # Agent views for the audio app. Every module in this package is
2
+ # imported at startup, and its module-level `@agent_view` functions are
3
+ # registered; `agent_views.py` is the conventional home for them.
@@ -0,0 +1,11 @@
1
+ """The audio app as places."""
2
+ from graphcore.agent_frontend import agent_view
3
+
4
+
5
+ @agent_view('audio.recording', default_for=['audio.Recording'])
6
+ async def recording(ctx, entity):
7
+ return [
8
+ f"Dictation for `{entity.purpose}`, take {entity.take}.",
9
+ entity.text or "Nothing dictated yet.",
10
+ "Recording needs a microphone, so it happens in the web app.",
11
+ ]
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: graphcore-audio
3
+ Version: 0.4.0
4
+ Summary: GraphCore app: audio
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Repository, https://github.com/graphcore-org/graphcore
7
+ Requires-Python: >=3.13
8
+ License-File: LICENSE
9
+ License-File: NOTICE
10
+ Requires-Dist: graphcore-kernel==0.4.0
11
+ Requires-Dist: openai<3,>=2
12
+ Dynamic: license-file
@@ -0,0 +1,36 @@
1
+ audio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ audio/apps.py,sha256=ZnbqM10srPPKKx1dkheBKFbukAaCzva3ExY8EhG8qHA,575
3
+ audio/authorization.py,sha256=01yWYqyXDCmMNnLbubcmZ05GWCm_PTnut719mNjt3qY,610
4
+ audio/conf.py,sha256=x8ImwW5GVXO-NVvMl6WtQhsPcFJlcsmo1zg7WPiyTPc,838
5
+ audio/models.py,sha256=sCdOJgVaPEDWFaPsgxn_LD78fiwOqdzJmI7KKdsLA_w,307
6
+ audio/persistence.py,sha256=eDXCS4x9FY8Mp5VifMpUGtAe3TAKKGhQhAk2a5agsg4,175
7
+ audio/test_settings.py,sha256=ttXU7HH8EpPaFbbeO9Nweze32ardC7PvEF1OnqjfOdA,291
8
+ audio/entities/__init__.py,sha256=pRiD0BkgO-KVz5Vsny5neB2rJtWxX5VuF524KWNcmIU,397
9
+ audio/entities/recording.py,sha256=zJaMPMJwzsTtTQr_HKSjf3EqGdTg4hZjEbZH7R1CZW4,271
10
+ audio/migrations/0001_initial.py,sha256=StZiTt6rHAGqWbpznEmoFXr3lyUaGff5NFtwK03yqBs,873
11
+ audio/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ audio/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ audio/providers/fake.py,sha256=KC9c8tcVD1k2vdDQ9CgFC9Fbq0TFzEDwjl2Peh9DC28,1288
14
+ audio/providers/openai.py,sha256=HUixAXpElhXjCZEj0H4PDZfla9bBtp_a-e4yOYlFNXQ,2288
15
+ audio/providers/port.py,sha256=W8zP3N5N1e2iTpqOID0L0R8zrUgGL6dF2nKAKU92dOY,1026
16
+ audio/providers/registry.py,sha256=Ii_M8XEiMtxZ2vrUjsTGGy96f5tMYu6acAd8h2cE1EA,1146
17
+ audio/specs/__init__.py,sha256=BvPz3nZglqaFsbSa6LjDs5G2vyuDaMlwUmQ0kAKDfDU,191
18
+ audio/specs/dsl.py,sha256=vEEJ8sd825vGtdJIrd60lZug5Gd42zppg1DzMdB6TMo,4608
19
+ audio/specs/test_clients.py,sha256=ZAe6z2OXlYvJRAHAenfwrvmQFMbUF0NUD5RC0mOmK7g,725
20
+ audio/specs/test_dictation.py,sha256=D6YLppn8V8lBKTCl1atLkzjxSPstRFunsw7ELrmqSn8,3366
21
+ audio/specs/test_privacy.py,sha256=Wt8fSKBOvqZk3VduzznlbxveXINsaN0IX3z5nCamCfM,1491
22
+ audio/specs/test_vendor.py,sha256=pVgJoSppJUpWNofLkm5M9BswELUH8XY2d-S7sA-DdKo,2239
23
+ audio/strategies/__init__.py,sha256=mqi2ur8Ctp7KIYdZDDvGJMCehOrBqxpnr9aT7cWrrRk,411
24
+ audio/strategies/recordings.py,sha256=aFAKoWnl4rz61lue245KnFSowNWsO7vvxQI2gHVnlEk,4007
25
+ audio/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ audio/tests/test_openai_adapter.py,sha256=WfEH7WJ0qzFpmsTqubv8WgCdgUVwbCF4iXUFyrRjLDY,3122
27
+ audio/tests/test_recordings.py,sha256=uxjRs0rAtIo0WzQs9a5GQ5PwNJoVTvEmdLNzc2kMyXI,6182
28
+ audio_agent_frontend/__init__.py,sha256=gPPvb46ES-ybdxHMyDk4wcvph3NMkcSY3_5w7J1a-H4,203
29
+ audio_agent_frontend/agent_views.py,sha256=IRJt3quv5MGVdf848jXz7D1DLI4NWYmnqTOnDVb4VJ0,383
30
+ graphcore_audio-0.4.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
31
+ graphcore_audio-0.4.0.dist-info/licenses/NOTICE,sha256=O2mV23MKwYlPOz9-8wsTSRNH3noH5-ie_sFFAvoOc_A,40
32
+ graphcore_audio-0.4.0.dist-info/METADATA,sha256=TRzDe6aZZ-TR0w3RdtRUecqIU_uQQQkmWxD0lZ8XUPc,344
33
+ graphcore_audio-0.4.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
34
+ graphcore_audio-0.4.0.dist-info/entry_points.txt,sha256=aLREOPS1QOgduJSUSxReHJYlV5Vw_VddYzhBoB9bXDg,89
35
+ graphcore_audio-0.4.0.dist-info/top_level.txt,sha256=wJ3NfyNbXkZEsA7wVLOHJwZgWXgmd4NflBWfL6r0zyM,27
36
+ graphcore_audio-0.4.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,5 @@
1
+ [graphcore.agent_frontends]
2
+ audio = audio_agent_frontend
3
+
4
+ [graphcore.apps]
5
+ audio = audio
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ GraphCore
2
+ Copyright 2026 Andrew Passero
@@ -0,0 +1,2 @@
1
+ audio
2
+ audio_agent_frontend