mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
refactor: 查询profile时返回stt配置
This commit is contained in:
parent
eb81d6d010
commit
7380507b55
|
|
@ -690,6 +690,10 @@ class ApplicationSerializer(serializers.Serializer):
|
|||
raise AppUnauthorizedFailed(500, "非法用户")
|
||||
return ApplicationSerializer.Query.reset_application(
|
||||
{**ApplicationSerializer.ApplicationModel(application).data,
|
||||
'stt_model_id': application.stt_model_id,
|
||||
'tts_model_id': application.tts_model_id,
|
||||
'stt_model_enable': application.stt_model_enable,
|
||||
'tts_model_enable': application.tts_model_enable,
|
||||
'show_source': application_access_token.show_source})
|
||||
|
||||
@transaction.atomic
|
||||
|
|
|
|||
|
|
@ -539,7 +539,7 @@ class Application(APIView):
|
|||
authentication_classes = [TokenAuth]
|
||||
|
||||
@action(methods=['POST'], detail=False)
|
||||
@has_permissions(ViewPermission([RoleConstants.ADMIN, RoleConstants.USER],
|
||||
@has_permissions(ViewPermission([RoleConstants.ADMIN, RoleConstants.USER, RoleConstants.APPLICATION_ACCESS_TOKEN],
|
||||
[lambda r, keywords: Permission(group=Group.APPLICATION,
|
||||
operate=Operate.USE,
|
||||
dynamic_tag=keywords.get(
|
||||
|
|
@ -554,7 +554,7 @@ class Application(APIView):
|
|||
authentication_classes = [TokenAuth]
|
||||
|
||||
@action(methods=['POST'], detail=False)
|
||||
@has_permissions(ViewPermission([RoleConstants.ADMIN, RoleConstants.USER],
|
||||
@has_permissions(ViewPermission([RoleConstants.ADMIN, RoleConstants.USER, RoleConstants.APPLICATION_ACCESS_TOKEN],
|
||||
[lambda r, keywords: Permission(group=Group.APPLICATION,
|
||||
operate=Operate.USE,
|
||||
dynamic_tag=keywords.get(
|
||||
|
|
|
|||
|
|
@ -666,15 +666,12 @@ const uploadRecording = async (audioBlob: Blob) => {
|
|||
try {
|
||||
const formData = new FormData()
|
||||
formData.append('file', audioBlob, 'recording.mp3')
|
||||
|
||||
if (id) {
|
||||
applicationApi.postSpeechToText(id as string, formData, loading)
|
||||
.then((response) => {
|
||||
console.log('上传成功:', response.data)
|
||||
inputValue.value = response.data
|
||||
// chatMessage(null, res.data)
|
||||
})
|
||||
}
|
||||
applicationApi.postSpeechToText(props.data.id as string, formData, loading)
|
||||
.then((response) => {
|
||||
console.log('上传成功:', response.data)
|
||||
inputValue.value = response.data
|
||||
// chatMessage(null, res.data)
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
console.error('上传失败:', error)
|
||||
|
|
@ -682,36 +679,33 @@ const uploadRecording = async (audioBlob: Blob) => {
|
|||
}
|
||||
|
||||
const playAnswerText = (text: string) => {
|
||||
if (id) {
|
||||
console.log(text)
|
||||
applicationApi.postTextToSpeech(id as string, { 'text': text }, loading)
|
||||
.then((res: any) => {
|
||||
applicationApi.postTextToSpeech(props.data.id as string, { 'text': text }, loading)
|
||||
.then((res: any) => {
|
||||
|
||||
// 假设我们有一个 MP3 文件的字节数组
|
||||
// 创建 Blob 对象
|
||||
const blob = new Blob([res], { type: 'audio/mp3' })
|
||||
// 假设我们有一个 MP3 文件的字节数组
|
||||
// 创建 Blob 对象
|
||||
const blob = new Blob([res], { type: 'audio/mp3' })
|
||||
|
||||
// 创建对象 URL
|
||||
const url = URL.createObjectURL(blob)
|
||||
// 创建对象 URL
|
||||
const url = URL.createObjectURL(blob)
|
||||
|
||||
// 测试blob是否能正常播放
|
||||
// const link = document.createElement('a')
|
||||
// link.href = window.URL.createObjectURL(blob)
|
||||
// link.download = "abc.mp3"
|
||||
// link.click()
|
||||
// 测试blob是否能正常播放
|
||||
// const link = document.createElement('a')
|
||||
// link.href = window.URL.createObjectURL(blob)
|
||||
// link.download = "abc.mp3"
|
||||
// link.click()
|
||||
|
||||
// 检查 audioPlayer 是否已经引用了 DOM 元素
|
||||
if (audioPlayer.value instanceof HTMLAudioElement) {
|
||||
audioPlayer.value.src = url;
|
||||
audioPlayer.value.play(); // 自动播放音频
|
||||
} else {
|
||||
console.error("audioPlayer.value is not an instance of HTMLAudioElement");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('err: ', err)
|
||||
})
|
||||
}
|
||||
// 检查 audioPlayer 是否已经引用了 DOM 元素
|
||||
if (audioPlayer.value instanceof HTMLAudioElement) {
|
||||
audioPlayer.value.src = url;
|
||||
audioPlayer.value.play(); // 自动播放音频
|
||||
} else {
|
||||
console.error("audioPlayer.value is not an instance of HTMLAudioElement");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('err: ', err)
|
||||
})
|
||||
}
|
||||
|
||||
function setScrollBottom() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue