Files
conjurer/stream_test.py
T
gitea af29b857b1 Tag: 1.15
Intermediate commits (oldest → newest):
- Testing transcribe
- Additions before wsl purge
- Transcribe cog
- Tst
- fx
- fx
- Fx
- Fix
- Testing for transcribe
- work
- Test
- Att2
- Att 3
- saving
- ffmpeg
- Fsink wsink
- fx
- msink
- tst
- Fix
- 2
- Events
- fx1
- fx2
- fix
- 11
- A
- TR
- Fix
- Fix
- Revert
- fx
- fx
- Fix
- fx
- fx
- fx
- fx
- aaa
- FX
- fx
- :S
- :)
- aaaa
- fx
- fgf
- Fx
- aa
- Fx
- ff
- aa
- as
- zzz
- fx
- :)
- fx
- fx
- addfs
- fa
- Test
- Fixtime
- FX
- Fix
- aa
- FX
- test
- Fa
- fix
- test
- fix
- fx
- aaa
- fix
- fx
- Hack na hacku hackiem pogania
- Fix fo hack
- Fix asyncio sleep
- tst
- tst
- 1
- tst 2
- ii
- Thread
- asa
- Fx
- Fix
- Fx test
- fx
- tst
- asynv
- async
- fx
- fx
- Test
- SAy
- ass
- Bugfix
- fx
- fx
- test
- fx
- fx
- fx
- fx
- Masha wants to code
- tesst
- test
- Fur ktosia!
- Last łan for todej mejbi
- test
- Fixing debug levels
- Clock tests
2025-10-30 16:59:12 +01:00

63 lines
1.6 KiB
Python

# Start by making sure the `assemblyai` package is installed.
# If not, you can install it by running the following command:
# pip install -U assemblyai
#
# Then, make sure you have PyAudio installed: https://pypi.org/project/PyAudio/
#
# Note: Some macOS users might need to use `pip3` instead of `pip`.
import pyaudio
import assemblyai as aai
aai.settings.api_key = "aa9962f0088a449a9c4ab2361e96cc08"
def on_open(session_opened: aai.RealtimeSessionOpened):
"This function is called when the connection has been established."
print("Session ID:", session_opened.session_id)
def on_data(transcript: aai.RealtimeTranscript):
"This function is called when a new transcript has been received."
if not transcript.text:
return
if isinstance(transcript, aai.RealtimeFinalTranscript):
print(transcript.text, end="\r\n")
else:
print(transcript.text, end="\r")
def on_error(error: aai.RealtimeError):
"This function is called when the connection has been closed."
print("An error occured:", error)
def on_close():
"This function is called when the connection has been closed."
print("Closing Session")
transcriber = aai.RealtimeTranscriber(
on_data=on_data,
on_error=on_error,
sample_rate=44_100,
on_open=on_open, # optional
on_close=on_close, # optional
)
pa = pyaudio.PyAudio()
for i in range(pa.get_device_count()):
print (pa.get_device_info_by_index(i))
# Start the connection
#transcriber.connect()
# Open a microphone stream
#microphone_stream = aai.extras.MicrophoneStream()
# Press CTRL+C to abort
#transcriber.stream(microphone_stream)
#transcriber.close()