main
 1#!/usr/bin/env rye run python
 2
 3import asyncio
 4
 5from openai import AsyncOpenAI
 6from openai.helpers import Microphone
 7
 8# gets OPENAI_API_KEY from your environment variables
 9openai = AsyncOpenAI()
10
11
12async def main() -> None:
13    print("Recording for the next 10 seconds...")
14    recording = await Microphone(timeout=10).record()
15    print("Recording complete")
16    transcription = await openai.audio.transcriptions.create(
17        model="whisper-1",
18        file=recording,
19    )
20
21    print(transcription.text)
22
23
24if __name__ == "__main__":
25    asyncio.run(main())