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