File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
3
import asyncio
4
+ from typing import TYPE_CHECKING
4
5
5
6
import numpy as np
6
7
import sounddevice as sd
13
14
14
15
from agents .voice import StreamedAudioInput , VoicePipeline
15
16
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
17
+ # Import MyWorkflow class - handle both module and package use cases
18
+ if TYPE_CHECKING :
19
+ # For type checking, use the relative import
22
20
from .my_workflow import MyWorkflow
21
+ else :
22
+ # At runtime, try both import styles
23
+ try :
24
+ # Try relative import first (when used as a package)
25
+ from .my_workflow import MyWorkflow
26
+ except ImportError :
27
+ # Fall back to direct import (when run as a script)
28
+ from my_workflow import MyWorkflow
23
29
24
30
CHUNK_LENGTH_S = 0.05 # 100ms
25
31
SAMPLE_RATE = 24000
You can’t perform that action at this time.
0 commit comments