|
@@ -5,6 +5,8 @@ import {
|
|
|
PlayCircleOutlined,
|
|
PlayCircleOutlined,
|
|
|
StopOutlined,
|
|
StopOutlined,
|
|
|
ReloadOutlined,
|
|
ReloadOutlined,
|
|
|
|
|
+ EyeOutlined,
|
|
|
|
|
+ EyeInvisibleOutlined,
|
|
|
} from "@ant-design/icons"
|
|
} from "@ant-design/icons"
|
|
|
import { useNavigate } from "react-router-dom"
|
|
import { useNavigate } from "react-router-dom"
|
|
|
import { genRandomUserId } from "@/common"
|
|
import { genRandomUserId } from "@/common"
|
|
@@ -19,6 +21,9 @@ import type {
|
|
|
IRtcManagerAdapter,
|
|
IRtcManagerAdapter,
|
|
|
} from "../../../packages/stt-sdk-core/src/types"
|
|
} from "../../../packages/stt-sdk-core/src/types"
|
|
|
|
|
|
|
|
|
|
+// 导入字幕显示组件
|
|
|
|
|
+import CaptionDisplay from "./components/caption-display"
|
|
|
|
|
+
|
|
|
const { Title, Text } = Typography
|
|
const { Title, Text } = Typography
|
|
|
|
|
|
|
|
const SdkTestPage = () => {
|
|
const SdkTestPage = () => {
|
|
@@ -37,6 +42,8 @@ const SdkTestPage = () => {
|
|
|
const [transcriptionStatus, setTranscriptionStatus] = useState<string>("idle")
|
|
const [transcriptionStatus, setTranscriptionStatus] = useState<string>("idle")
|
|
|
const [testResults, setTestResults] = useState<string[]>([])
|
|
const [testResults, setTestResults] = useState<string[]>([])
|
|
|
const [sttData, setSttData] = useState<any>({})
|
|
const [sttData, setSttData] = useState<any>({})
|
|
|
|
|
+ const [captionVisible, setCaptionVisible] = useState(true)
|
|
|
|
|
+ const [captionLanguages, setCaptionLanguages] = useState<string[]>(["live"])
|
|
|
|
|
|
|
|
// 添加测试日志
|
|
// 添加测试日志
|
|
|
const addTestLog = (log: string) => {
|
|
const addTestLog = (log: string) => {
|
|
@@ -57,6 +64,28 @@ const SdkTestPage = () => {
|
|
|
setTranscriptionStatus("stopped")
|
|
setTranscriptionStatus("stopped")
|
|
|
addTestLog("📢 转录状态更新: 转录已停止")
|
|
addTestLog("📢 转录状态更新: 转录已停止")
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 如果有转录内容,记录到日志
|
|
|
|
|
+ if (data.transcribe1 || data.transcribe2) {
|
|
|
|
|
+ addTestLog(`📝 转录结果: ${data.transcribe1 || data.transcribe2}`)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果有翻译内容,记录到日志
|
|
|
|
|
+ if (data.translate1List?.length) {
|
|
|
|
|
+ data.translate1List.forEach((text: string, index: number) => {
|
|
|
|
|
+ if (text) {
|
|
|
|
|
+ addTestLog(`🌐 翻译${index + 1}: ${text}`)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (data.translate2List?.length) {
|
|
|
|
|
+ data.translate2List.forEach((text: string, index: number) => {
|
|
|
|
|
+ if (text) {
|
|
|
|
|
+ addTestLog(`🌐 翻译${index + 2}: ${text}`)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 初始化SDK
|
|
// 初始化SDK
|
|
@@ -274,6 +303,24 @@ const SdkTestPage = () => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 切换字幕显示
|
|
|
|
|
+ const toggleCaptionVisibility = () => {
|
|
|
|
|
+ setCaptionVisible(!captionVisible)
|
|
|
|
|
+ addTestLog(`📺 字幕显示: ${!captionVisible ? "开启" : "关闭"}`)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 切换语言显示
|
|
|
|
|
+ const toggleLanguage = (language: string) => {
|
|
|
|
|
+ setCaptionLanguages((prev) => {
|
|
|
|
|
+ if (prev.includes(language)) {
|
|
|
|
|
+ return prev.filter((lang) => lang !== language)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return [...prev, language]
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ addTestLog(`🌐 语言显示: ${captionLanguages.includes(language) ? "关闭" : "开启"} ${language}`)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 返回主应用
|
|
// 返回主应用
|
|
|
const goToMainApp = () => {
|
|
const goToMainApp = () => {
|
|
|
nav("/home")
|
|
nav("/home")
|
|
@@ -512,6 +559,54 @@ const SdkTestPage = () => {
|
|
|
</Button>
|
|
</Button>
|
|
|
</Space>
|
|
</Space>
|
|
|
</Card>
|
|
</Card>
|
|
|
|
|
+
|
|
|
|
|
+ <Card
|
|
|
|
|
+ title={
|
|
|
|
|
+ <Space>
|
|
|
|
|
+ <span>📺 实时转录显示</span>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ icon={captionVisible ? <EyeOutlined /> : <EyeInvisibleOutlined />}
|
|
|
|
|
+ onClick={toggleCaptionVisibility}
|
|
|
|
|
+ >
|
|
|
|
|
+ {captionVisible ? "隐藏" : "显示"}
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ }
|
|
|
|
|
+ className={styles.captionCard}
|
|
|
|
|
+ extra={
|
|
|
|
|
+ <Space>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ type={captionLanguages.includes("live") ? "primary" : "default"}
|
|
|
|
|
+ onClick={() => toggleLanguage("live")}
|
|
|
|
|
+ >
|
|
|
|
|
+ 原文
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ type={captionLanguages.includes("translate1") ? "primary" : "default"}
|
|
|
|
|
+ onClick={() => toggleLanguage("translate1")}
|
|
|
|
|
+ >
|
|
|
|
|
+ 翻译1
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ type={captionLanguages.includes("translate2") ? "primary" : "default"}
|
|
|
|
|
+ onClick={() => toggleLanguage("translate2")}
|
|
|
|
|
+ >
|
|
|
|
|
+ 翻译2
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ }
|
|
|
|
|
+ >
|
|
|
|
|
+ <CaptionDisplay
|
|
|
|
|
+ visible={captionVisible}
|
|
|
|
|
+ captionLanguages={captionLanguages}
|
|
|
|
|
+ sttData={sttData}
|
|
|
|
|
+ />
|
|
|
|
|
+ </Card>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|