Skip to content

Commit 9473c78

Browse files
committed
Fix type-checking for circular dependency in voice streamed example
1 parent 7432347 commit 9473c78

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/voice/streamed/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
from agents.voice import StreamedAudioInput, VoicePipeline
1515

16-
# Use absolute import when running as script directly
17-
try:
18-
# First try relative import (for package use)
16+
# Use absolute or relative import based on context
17+
if __name__ == "__main__":
18+
# When running as script, use absolute import
19+
from my_workflow import MyWorkflow # type: ignore
20+
else:
21+
# When imported as module, use relative import
1922
from .my_workflow import MyWorkflow
20-
except ImportError:
21-
# Fall back to direct import (for script use)
22-
from my_workflow import MyWorkflow
2323

2424
CHUNK_LENGTH_S = 0.05 # 100ms
2525
SAMPLE_RATE = 24000

0 commit comments

Comments
 (0)