liumaolin
commited on
Commit
·
619c761
1
Parent(s):
2414221
Refactor imports across services: replace `services.core` module references with `core` for consistency and maintainability; remove unused `Queue` imports.
Browse files- src/VoiceDialogue/api/core/service_factories.py +3 -3
- src/VoiceDialogue/{services/core → core}/__init__.py +0 -0
- src/VoiceDialogue/{services/core → core}/base.py +0 -0
- src/VoiceDialogue/{services/core → core}/constants.py +0 -0
- src/VoiceDialogue/{services/core → core}/enums.py +1 -1
- src/VoiceDialogue/{services/core → core}/state_manager.py +0 -0
- src/VoiceDialogue/main.py +5 -5
- src/VoiceDialogue/services/audio/aec_audio_capture.py +1 -1
- src/VoiceDialogue/services/audio/audio_answer.py +2 -2
- src/VoiceDialogue/services/audio/audio_player.py +3 -4
- src/VoiceDialogue/services/core/queue.py +0 -7
- src/VoiceDialogue/services/speech/asr_service.py +2 -2
- src/VoiceDialogue/services/speech/speech_monitor.py +3 -3
- src/VoiceDialogue/services/text/text_generator.py +2 -2
src/VoiceDialogue/api/core/service_factories.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
from
|
| 2 |
-
from services.audio.audio_generator import BaseTTSConfig, tts_config_registry
|
| 3 |
-
from services.core.constants import (
|
| 4 |
transcribed_text_queue, text_input_queue, audio_output_queue,
|
| 5 |
audio_frames_queue, user_voice_queue
|
| 6 |
)
|
|
|
|
|
|
|
| 7 |
from services.speech import SpeechStateMonitor, ASRWorker
|
| 8 |
from services.text.text_generator import LLMResponseGenerator
|
| 9 |
from .service_manager import ServiceDefinition
|
|
|
|
| 1 |
+
from core.constants import (
|
|
|
|
|
|
|
| 2 |
transcribed_text_queue, text_input_queue, audio_output_queue,
|
| 3 |
audio_frames_queue, user_voice_queue
|
| 4 |
)
|
| 5 |
+
from services.audio import EchoCancellingAudioCapture, TTSAudioGenerator, AudioStreamPlayer
|
| 6 |
+
from services.audio.audio_generator import BaseTTSConfig, tts_config_registry
|
| 7 |
from services.speech import SpeechStateMonitor, ASRWorker
|
| 8 |
from services.text.text_generator import LLMResponseGenerator
|
| 9 |
from .service_manager import ServiceDefinition
|
src/VoiceDialogue/{services/core → core}/__init__.py
RENAMED
|
File without changes
|
src/VoiceDialogue/{services/core → core}/base.py
RENAMED
|
File without changes
|
src/VoiceDialogue/{services/core → core}/constants.py
RENAMED
|
File without changes
|
src/VoiceDialogue/{services/core → core}/enums.py
RENAMED
|
@@ -4,4 +4,4 @@ import enum
|
|
| 4 |
class AudioState(enum.Enum):
|
| 5 |
"""音频播放状态枚举"""
|
| 6 |
DROP = 0
|
| 7 |
-
PLAYING = 1
|
|
|
|
| 4 |
class AudioState(enum.Enum):
|
| 5 |
"""音频播放状态枚举"""
|
| 6 |
DROP = 0
|
| 7 |
+
PLAYING = 1
|
src/VoiceDialogue/{services/core → core}/state_manager.py
RENAMED
|
File without changes
|
src/VoiceDialogue/main.py
CHANGED
|
@@ -5,17 +5,17 @@ from pathlib import Path
|
|
| 5 |
|
| 6 |
import uvicorn
|
| 7 |
|
| 8 |
-
from
|
| 9 |
-
from services.audio.audio_answer import TTSAudioGenerator
|
| 10 |
-
from services.audio.audio_generator.models import tts_config_registry, TTSConfigType
|
| 11 |
-
from services.audio.audio_player import AudioStreamPlayer
|
| 12 |
-
from services.core.constants import (
|
| 13 |
audio_frames_queue,
|
| 14 |
user_voice_queue,
|
| 15 |
transcribed_text_queue,
|
| 16 |
text_input_queue,
|
| 17 |
audio_output_queue
|
| 18 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
from services.speech.asr_service import ASRWorker
|
| 20 |
from services.speech.speech_monitor import SpeechStateMonitor
|
| 21 |
from services.text.text_generator import LLMResponseGenerator
|
|
|
|
| 5 |
|
| 6 |
import uvicorn
|
| 7 |
|
| 8 |
+
from core.constants import (
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
audio_frames_queue,
|
| 10 |
user_voice_queue,
|
| 11 |
transcribed_text_queue,
|
| 12 |
text_input_queue,
|
| 13 |
audio_output_queue
|
| 14 |
)
|
| 15 |
+
from services.audio.aec_audio_capture import EchoCancellingAudioCapture
|
| 16 |
+
from services.audio.audio_answer import TTSAudioGenerator
|
| 17 |
+
from services.audio.audio_generator.models import tts_config_registry
|
| 18 |
+
from services.audio.audio_player import AudioStreamPlayer
|
| 19 |
from services.speech.asr_service import ASRWorker
|
| 20 |
from services.speech.speech_monitor import SpeechStateMonitor
|
| 21 |
from services.text.text_generator import LLMResponseGenerator
|
src/VoiceDialogue/services/audio/aec_audio_capture.py
CHANGED
|
@@ -9,7 +9,7 @@ import time
|
|
| 9 |
import numpy as np
|
| 10 |
|
| 11 |
from config.paths import LIBRARIES_PATH
|
| 12 |
-
from
|
| 13 |
|
| 14 |
|
| 15 |
class EchoCancellingAudioCapture(BaseThread):
|
|
|
|
| 9 |
import numpy as np
|
| 10 |
|
| 11 |
from config.paths import LIBRARIES_PATH
|
| 12 |
+
from core.base import BaseThread
|
| 13 |
|
| 14 |
|
| 15 |
class EchoCancellingAudioCapture(BaseThread):
|
src/VoiceDialogue/services/audio/audio_answer.py
CHANGED
|
@@ -2,9 +2,9 @@ import time
|
|
| 2 |
from multiprocessing import Queue
|
| 3 |
from queue import Empty
|
| 4 |
|
|
|
|
|
|
|
| 5 |
from models.voice_task import VoiceTask
|
| 6 |
-
from services.core.base import BaseThread
|
| 7 |
-
from services.core.constants import dropped_audio_cache, user_still_speaking_event, voice_state_manager
|
| 8 |
from .audio_generator import tts_manager, BaseTTSConfig
|
| 9 |
|
| 10 |
|
|
|
|
| 2 |
from multiprocessing import Queue
|
| 3 |
from queue import Empty
|
| 4 |
|
| 5 |
+
from core.base import BaseThread
|
| 6 |
+
from core.constants import dropped_audio_cache, user_still_speaking_event, voice_state_manager
|
| 7 |
from models.voice_task import VoiceTask
|
|
|
|
|
|
|
| 8 |
from .audio_generator import tts_manager, BaseTTSConfig
|
| 9 |
|
| 10 |
|
src/VoiceDialogue/services/audio/audio_player.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import tempfile
|
| 2 |
-
import time
|
| 3 |
from collections import OrderedDict
|
| 4 |
from multiprocessing import Queue
|
| 5 |
from queue import Empty
|
|
@@ -7,12 +6,12 @@ from queue import Empty
|
|
| 7 |
import soundfile as sf
|
| 8 |
from playsound import playsound
|
| 9 |
|
| 10 |
-
from
|
| 11 |
-
from
|
| 12 |
-
from services.core.constants import (
|
| 13 |
user_still_speaking_event, voice_state_manager, dropped_audio_cache, chat_history_cache,
|
| 14 |
silence_over_threshold_event
|
| 15 |
)
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
class AudioStreamPlayer(BaseThread):
|
|
|
|
| 1 |
import tempfile
|
|
|
|
| 2 |
from collections import OrderedDict
|
| 3 |
from multiprocessing import Queue
|
| 4 |
from queue import Empty
|
|
|
|
| 6 |
import soundfile as sf
|
| 7 |
from playsound import playsound
|
| 8 |
|
| 9 |
+
from core.base import BaseThread
|
| 10 |
+
from core.constants import (
|
|
|
|
| 11 |
user_still_speaking_event, voice_state_manager, dropped_audio_cache, chat_history_cache,
|
| 12 |
silence_over_threshold_event
|
| 13 |
)
|
| 14 |
+
from models.voice_task import VoiceTask
|
| 15 |
|
| 16 |
|
| 17 |
class AudioStreamPlayer(BaseThread):
|
src/VoiceDialogue/services/core/queue.py
DELETED
|
@@ -1,7 +0,0 @@
|
|
| 1 |
-
from multiprocessing import Queue
|
| 2 |
-
|
| 3 |
-
audio_frames_queue = Queue()
|
| 4 |
-
user_voice_queue = Queue()
|
| 5 |
-
transcribed_text_queue = Queue()
|
| 6 |
-
generated_answer_queue = Queue()
|
| 7 |
-
tts_generated_audio_queue = Queue()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/VoiceDialogue/services/speech/asr_service.py
CHANGED
|
@@ -4,9 +4,9 @@ from queue import Queue
|
|
| 4 |
|
| 5 |
import numpy as np
|
| 6 |
|
|
|
|
|
|
|
| 7 |
from models.voice_task import VoiceTask
|
| 8 |
-
from services.core.base import BaseThread
|
| 9 |
-
from services.core.constants import user_still_speaking_event, voice_state_manager, dropped_audio_cache
|
| 10 |
from utils.cache import LRUCacheDict
|
| 11 |
from .asr import asr_manager
|
| 12 |
|
|
|
|
| 4 |
|
| 5 |
import numpy as np
|
| 6 |
|
| 7 |
+
from core.base import BaseThread
|
| 8 |
+
from core.constants import user_still_speaking_event, voice_state_manager, dropped_audio_cache
|
| 9 |
from models.voice_task import VoiceTask
|
|
|
|
|
|
|
| 10 |
from utils.cache import LRUCacheDict
|
| 11 |
from .asr import asr_manager
|
| 12 |
|
src/VoiceDialogue/services/speech/speech_monitor.py
CHANGED
|
@@ -14,11 +14,11 @@ import librosa
|
|
| 14 |
import numpy as np
|
| 15 |
|
| 16 |
from models.voice_task import VoiceTask
|
| 17 |
-
from
|
| 18 |
-
from
|
| 19 |
voice_state_manager, silence_over_threshold_event, user_still_speaking_event, current_session_id
|
| 20 |
)
|
| 21 |
-
from
|
| 22 |
|
| 23 |
|
| 24 |
class SpeechMonitorConfig:
|
|
|
|
| 14 |
import numpy as np
|
| 15 |
|
| 16 |
from models.voice_task import VoiceTask
|
| 17 |
+
from core.base import BaseThread
|
| 18 |
+
from core.constants import (
|
| 19 |
voice_state_manager, silence_over_threshold_event, user_still_speaking_event, current_session_id
|
| 20 |
)
|
| 21 |
+
from core.enums import AudioState
|
| 22 |
|
| 23 |
|
| 24 |
class SpeechMonitorConfig:
|
src/VoiceDialogue/services/text/text_generator.py
CHANGED
|
@@ -6,9 +6,9 @@ from langchain.memory import ConversationBufferWindowMemory
|
|
| 6 |
from langchain_core.chat_history import InMemoryChatMessageHistory
|
| 7 |
|
| 8 |
from config import paths
|
|
|
|
|
|
|
| 9 |
from models.voice_task import VoiceTask
|
| 10 |
-
from services.core.base import BaseThread
|
| 11 |
-
from services.core.constants import chat_history_cache
|
| 12 |
from services.text.langchain_llm import preprocess_sentence_text, \
|
| 13 |
create_langchain_chat_llamacpp_instance, create_langchain_pipeline, warmup_langchain_pipeline
|
| 14 |
|
|
|
|
| 6 |
from langchain_core.chat_history import InMemoryChatMessageHistory
|
| 7 |
|
| 8 |
from config import paths
|
| 9 |
+
from core.base import BaseThread
|
| 10 |
+
from core.constants import chat_history_cache
|
| 11 |
from models.voice_task import VoiceTask
|
|
|
|
|
|
|
| 12 |
from services.text.langchain_llm import preprocess_sentence_text, \
|
| 13 |
create_langchain_chat_llamacpp_instance, create_langchain_pipeline, warmup_langchain_pipeline
|
| 14 |
|