Skip to content

Commit d9f3b0b

Browse files
Michelle AsuamahMichelle Asuamah
authored andcommitted
fix identation issues
1 parent 58fba18 commit d9f3b0b

File tree

2 files changed

+48
-52
lines changed

2 files changed

+48
-52
lines changed

fern/pages/01-getting-started/transcribe-streaming-audio-from-a-microphone/python.mdx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@ import assemblyai as aai
3030
aai.settings.api_key = "<YOUR_API_KEY>"
3131

3232
def on_open(session_opened: aai.RealtimeSessionOpened):
33-
print("Session ID:", session_opened.session_id)
33+
print("Session ID:", session_opened.session_id)
3434

3535
def on_data(transcript: aai.RealtimeTranscript):
36-
if not transcript.text:
37-
return
36+
if not transcript.text:
37+
return
3838

3939
if isinstance(transcript, aai.RealtimeFinalTranscript):
4040
print(transcript.text, end="\r\n")
4141
else:
4242
print(transcript.text, end="\r")
4343

4444
def on_error(error: aai.RealtimeError):
45-
print("An error occurred:", error)
45+
print("An error occurred:", error)
4646

4747
def on_close():
48-
print("Closing Session")
48+
print("Closing Session")
4949

5050
transcriber = aai.RealtimeTranscriber(
51-
sample_rate=16_000,
52-
on_data=on_data,
53-
on_error=on_error,
54-
on_open=on_open,
55-
on_close=on_close,
51+
sample_rate=16_000,
52+
on_data=on_data,
53+
on_error=on_error,
54+
on_open=on_open,
55+
on_close=on_close,
5656
)
5757

5858
transcriber.connect()
@@ -61,7 +61,6 @@ microphone_stream = aai.extras.MicrophoneStream(sample_rate=16_000)
6161
transcriber.stream(microphone_stream)
6262

6363
transcriber.close()
64-
6564
````
6665

6766
</Tab>
@@ -302,10 +301,10 @@ def on_open(session_opened: aai.RealtimeSessionOpened):
302301
print("Session ID:", session_opened.session_id)
303302

304303
def on_error(error: aai.RealtimeError):
305-
print("An error occurred:", error)
304+
print("An error occurred:", error)
306305

307306
def on_close():
308-
print("Closing Session")
307+
print("Closing Session")
309308

310309
````
311310

fern/pages/01-getting-started/transcribe-streaming-audio-from-a-microphone/typescript.mdx

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,69 +32,66 @@ import { AssemblyAI, RealtimeTranscript } from 'assemblyai'
3232
import { SoxRecording } from './sox.js'
3333

3434
const run = async () => {
35-
const client = new AssemblyAI({
36-
apiKey: '<YOUR_API_KEY>'
37-
})
35+
const client = new AssemblyAI({
36+
apiKey: '<YOUR_API_KEY>'
37+
})
3838

39-
const SAMPLE_RATE = 16_000
39+
const SAMPLE_RATE = 16_000
4040

41-
const transcriber = client.realtime.transcriber({
42-
sampleRate: SAMPLE_RATE
43-
})
41+
const transcriber = client.realtime.transcriber({
42+
sampleRate: SAMPLE_RATE
43+
})
4444

45-
transcriber.on('open', ({ sessionId }) => {
46-
console.log(`Session opened with ID: ${sessionId}`)
47-
})
45+
transcriber.on('open', ({ sessionId }) => {
46+
console.log(`Session opened with ID: ${sessionId}`)
47+
})
4848

49-
transcriber.on('error', (error: Error) => {
50-
console.error('Error:', error)
51-
})
49+
transcriber.on('error', (error: Error) => {
50+
console.error('Error:', error)
51+
})
5252

53-
transcriber.on('close', (code: number, reason: string) =>
54-
console.log('Session closed:', code, reason)
55-
)
53+
transcriber.on('close', (code: number, reason: string) => {
54+
console.log('Session closed:', code, reason)
55+
})
5656

57-
transcriber.on('transcript', (transcript: RealtimeTranscript) => {
58-
if (!transcript.text) {
59-
return
60-
}
57+
transcriber.on('transcript', (transcript: RealtimeTranscript) => {
58+
if (!transcript.text) {
59+
return
60+
}
6161

6262
if (transcript.message_type === 'PartialTranscript') {
6363
console.log('Partial:', transcript.text)
6464
} else {
6565
console.log('Final:', transcript.text)
6666
}
67+
})
6768

68-
})
69-
70-
console.log('Connecting to real-time transcript service')
71-
await transcriber.connect()
69+
console.log('Connecting to real-time transcript service')
70+
await transcriber.connect()
7271

73-
console.log('Starting recording')
74-
const recording = new SoxRecording({
75-
channels: 1,
76-
sampleRate: SAMPLE_RATE,
77-
audioType: 'wav' // Linear PCM
78-
})
72+
console.log('Starting recording')
73+
const recording = new SoxRecording({
74+
channels: 1,
75+
sampleRate: SAMPLE_RATE,
76+
audioType: 'wav' // Linear PCM
77+
})
7978

80-
recording.stream().pipeTo(transcriber.stream())
79+
recording.stream().pipeTo(transcriber.stream())
8180

82-
// Stop recording and close connection using Ctrl-C.
83-
process.on('SIGINT', async function () {
84-
console.log()
85-
console.log('Stopping recording')
86-
recording.stop()
81+
// Stop recording and close connection using Ctrl-C.
82+
process.on('SIGINT', async () => {
83+
console.log()
84+
console.log('Stopping recording')
85+
recording.stop()
8786

8887
console.log('Closing real-time transcript connection')
8988
await transcriber.close()
9089

9190
process.exit()
92-
93-
})
91+
})
9492
}
9593

9694
run()
97-
9895
````
9996
</Tab>
10097

0 commit comments

Comments
 (0)