|
|
@@ -27,7 +27,6 @@ const SdkTestPage = () => {
|
|
|
const [rtmManager, setRtmManager] = useState<IRtmManagerAdapter | null>(null)
|
|
|
const [isSdkInitialized, setIsSdkInitialized] = useState(false)
|
|
|
const [isSttManagerInitialized, setIsSttManagerInitialized] = useState(false)
|
|
|
- const [isRtmManagerJoined, setIsRtmManagerJoined] = useState(false)
|
|
|
const [isTranscriptionActive, setIsTranscriptionActive] = useState(false)
|
|
|
const [transcriptionStatus, setTranscriptionStatus] = useState<string>("idle")
|
|
|
const [testResults, setTestResults] = useState<string[]>([])
|
|
|
@@ -75,9 +74,9 @@ const SdkTestPage = () => {
|
|
|
setIsSdkInitialized(true)
|
|
|
addTestLog("✅ SDK初始化成功")
|
|
|
|
|
|
- // 创建管理器
|
|
|
- const sttManager = newSdk.createSttManager()
|
|
|
+ // 创建管理器 - 先创建RTM管理器,然后创建STT管理器并传入RTM管理器
|
|
|
const rtmManager = newSdk.createRtmManager()
|
|
|
+ const sttManager = newSdk.createSttManager(rtmManager)
|
|
|
|
|
|
// 监听RTM管理器的事件
|
|
|
rtmManager.on("sttDataChanged", onSttDataChanged)
|
|
|
@@ -93,7 +92,7 @@ const SdkTestPage = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 初始化STT管理器
|
|
|
+ // 初始化STT管理器(会自动加入RTM频道)
|
|
|
const initializeSttManager = async () => {
|
|
|
if (!sttManager || !form) return
|
|
|
|
|
|
@@ -108,7 +107,7 @@ const SdkTestPage = () => {
|
|
|
})
|
|
|
|
|
|
setIsSttManagerInitialized(true)
|
|
|
- addTestLog("✅ STT管理器初始化成功")
|
|
|
+ addTestLog("✅ STT管理器初始化成功(已自动加入RTM频道)")
|
|
|
messageApi.success("STT管理器初始化成功")
|
|
|
} catch (error) {
|
|
|
addTestLog(`❌ STT管理器初始化失败: ${error}`)
|
|
|
@@ -116,29 +115,6 @@ const SdkTestPage = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 加入RTM频道
|
|
|
- const joinRtmChannel = async () => {
|
|
|
- if (!rtmManager || !form) return
|
|
|
-
|
|
|
- try {
|
|
|
- const values = form.getFieldsValue()
|
|
|
- addTestLog("开始加入RTM频道...")
|
|
|
-
|
|
|
- await rtmManager.join({
|
|
|
- channel: values.channel,
|
|
|
- userId: genRandomUserId().toString(),
|
|
|
- userName: values.userName,
|
|
|
- })
|
|
|
-
|
|
|
- setIsRtmManagerJoined(true)
|
|
|
- addTestLog("✅ RTM频道加入成功")
|
|
|
- messageApi.success("RTM频道加入成功")
|
|
|
- } catch (error) {
|
|
|
- addTestLog(`❌ RTM频道加入失败: ${error}`)
|
|
|
- messageApi.error(`RTM频道加入失败: ${error}`)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 开始转录
|
|
|
const startTranscription = async () => {
|
|
|
if (!sttManager) return
|
|
|
@@ -219,7 +195,6 @@ const SdkTestPage = () => {
|
|
|
rtmManager.off("sttDataChanged", onSttDataChanged)
|
|
|
await rtmManager.destroy()
|
|
|
setRtmManager(null)
|
|
|
- setIsRtmManagerJoined(false)
|
|
|
}
|
|
|
|
|
|
if (sdk) {
|
|
|
@@ -333,14 +308,6 @@ const SdkTestPage = () => {
|
|
|
{isSttManagerInitialized ? "✅ STT管理器已初始化" : "初始化STT管理器"}
|
|
|
</Button>
|
|
|
|
|
|
- <Button
|
|
|
- onClick={joinRtmChannel}
|
|
|
- disabled={!isSdkInitialized || isRtmManagerJoined}
|
|
|
- block
|
|
|
- >
|
|
|
- {isRtmManagerJoined ? "✅ RTM频道已加入" : "加入RTM频道"}
|
|
|
- </Button>
|
|
|
-
|
|
|
<Divider />
|
|
|
|
|
|
<Button
|