Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JJ_Game_Sort_Image
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
JJ_Game_Sort_Image
Commits
2e01e315
Commit
2e01e315
authored
Mar 31, 2026
by
JinWei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增文本转语音
parent
cbb605d2
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
213 additions
and
648 deletions
+213
-648
package-lock.json
form/package-lock.json
+158
-643
package.json
form/package.json
+3
-1
upload-video.component.ts
form/src/app/common/upload-video/upload-video.component.ts
+1
-1
form.component.html
form/src/app/form/form.component.html
+9
-2
form.component.ts
form/src/app/form/form.component.ts
+42
-1
No files found.
form/package-lock.json
View file @
2e01e315
This diff is collapsed.
Click to expand it.
form/package.json
View file @
2e01e315
...
@@ -27,9 +27,10 @@
...
@@ -27,9 +27,10 @@
"@tweenjs/tween.js"
:
"~18.5.0"
,
"@tweenjs/tween.js"
:
"~18.5.0"
,
"ali-oss"
:
"^6.5.1"
,
"ali-oss"
:
"^6.5.1"
,
"compressing"
:
"^1.5.0"
,
"compressing"
:
"^1.5.0"
,
"crypto-js"
:
"^4.2.0"
,
"ng-zorro-antd"
:
"^8.5.2"
,
"ng-zorro-antd"
:
"^8.5.2"
,
"querystring"
:
"^0.2.0"
,
"rxjs"
:
"~6.5.4"
,
"rxjs"
:
"~6.5.4"
,
"node-sass"
:
"4.0.0"
,
"spark-md5"
:
"^3.0.0"
,
"spark-md5"
:
"^3.0.0"
,
"tslib"
:
"^1.10.0"
,
"tslib"
:
"^1.10.0"
,
"zone.js"
:
"~0.10.2"
"zone.js"
:
"~0.10.2"
...
@@ -39,6 +40,7 @@
...
@@ -39,6 +40,7 @@
"@angular/cli"
:
"~9.0.3"
,
"@angular/cli"
:
"~9.0.3"
,
"@angular/compiler-cli"
:
"~9.0.2"
,
"@angular/compiler-cli"
:
"~9.0.2"
,
"@angular/language-service"
:
"~9.0.2"
,
"@angular/language-service"
:
"~9.0.2"
,
"@types/crypto-js"
:
"^4.2.2"
,
"@types/jasmine"
:
"~3.5.0"
,
"@types/jasmine"
:
"~3.5.0"
,
"@types/jasminewd2"
:
"~2.0.3"
,
"@types/jasminewd2"
:
"~2.0.3"
,
"@types/node"
:
"^12.11.1"
,
"@types/node"
:
"^12.11.1"
,
...
...
form/src/app/common/upload-video/upload-video.component.ts
View file @
2e01e315
...
@@ -5,7 +5,7 @@ import {HttpClient, HttpHeaders, HttpRequest, HttpEvent, HttpEventType, HttpResp
...
@@ -5,7 +5,7 @@ import {HttpClient, HttpHeaders, HttpRequest, HttpEvent, HttpEventType, HttpResp
import
{
NzMessageService
,
UploadChangeParam
,
UploadFile
,
UploadFileStatus
,
UploadXHRArgs
}
from
'
ng-zorro-antd
'
;
import
{
NzMessageService
,
UploadChangeParam
,
UploadFile
,
UploadFileStatus
,
UploadXHRArgs
}
from
'
ng-zorro-antd
'
;
import
{
DomSanitizer
,
SafeResourceUrl
}
from
'
@angular/platform-browser
'
;
import
{
DomSanitizer
,
SafeResourceUrl
}
from
'
@angular/platform-browser
'
;
import
cryptoJs
from
'
crypto-js
'
;
import
*
as
cryptoJs
from
'
crypto-js
'
;
import
{
v4
}
from
'
uuid
'
;
import
{
v4
}
from
'
uuid
'
;
function
httpHeadCall
(
requsetUrl
,
callback
)
{
function
httpHeadCall
(
requsetUrl
,
callback
)
{
...
...
form/src/app/form/form.component.html
View file @
2e01e315
...
@@ -155,7 +155,14 @@
...
@@ -155,7 +155,14 @@
<div
style=
"margin-top: 5px; display: flex; align-items: center; "
>
<div
style=
"margin-top: 5px; display: flex; align-items: center; "
>
<span
style=
""
>
文本:
</span>
<span
style=
""
>
文本:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
option
.
text
"
(
blur
)="
save
()"
style=
" width: 300px;"
>
<input
type=
"text"
nz-input
[(
ngModel
)]="
option
.
text
"
(
blur
)="
save
()"
style=
" width: 300px; margin-right: 8px;"
>
<app-audio-recorder
[
audioUrl
]="
option
.
audio_url
"
(
audioUploaded
)="
onItemAudioUploadSuccess
($
event
,
option
,
'
audio_url
')"
>
</app-audio-recorder>
<button
nz-button
nzType=
"primary"
(
click
)="
generateTTSHandle
(
option
,
option
.
text
,
'
audio_url
')"
style=
"width: 120px; height: 32px; margin-left: 8px;"
>
<i
nz-icon
nzType=
"plus-circle"
nzTheme=
"outline"
></i>
生成音频
</button>
</div>
</div>
<!-- <div style="margin-top: 5px; display: flex; align-items: center; ">
<!-- <div style="margin-top: 5px; display: flex; align-items: center; ">
<span style="">翻译:</span>
<span style="">翻译:</span>
...
@@ -175,7 +182,7 @@
...
@@ -175,7 +182,7 @@
</button>
</button>
</div>
</div>
<div
*
ngIf=
"ques.optionTypeAudio"
style=
"
margin-top: 10px; display: flex; align-items: center
;"
>
<div
*
ngIf=
"ques.optionTypeAudio"
style=
"
display: none
;"
>
<span
style=
""
>
音频:
</span>
<span
style=
""
>
音频:
</span>
<app-audio-recorder
[
audioUrl
]="
option
.
audio_url
"
<app-audio-recorder
[
audioUrl
]="
option
.
audio_url
"
(
audioUploaded
)="
onItemAudioUploadSuccess
($
event
,
option
,
'
audio_url
')"
>
(
audioUploaded
)="
onItemAudioUploadSuccess
($
event
,
option
,
'
audio_url
')"
>
...
...
form/src/app/form/form.component.ts
View file @
2e01e315
...
@@ -54,10 +54,51 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -54,10 +54,51 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
selectedWord
:
any
;
selectedWord
:
any
;
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
,
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
,
private
message
:
NzMessageService
,
private
http
:
HttpClient
)
{
private
message
:
NzMessageService
,
private
http
:
HttpClient
,
private
nzMessageService
:
NzMessageService
)
{
}
}
async
generateTTSHandle
(
obj
,
text
,
key
=
'
audio
'
)
{
if
(
!
text
)
{
this
.
nzMessageService
.
error
(
'
文本不能为空
'
);
return
;
}
this
.
nzMessageService
.
loading
(
'
生成音频中...
'
);
const
audioUrl
=
await
this
.
generateTTS
(
text
).
catch
((
e
)
=>
{
this
.
nzMessageService
.
error
(
'
生成音频失败
'
);
}).
finally
(()
=>
{
this
.
nzMessageService
.
remove
();
});
if
(
!
audioUrl
)
{
this
.
nzMessageService
.
error
(
'
生成音频失败,请稍后再试。
'
);
return
;
}
obj
[
key
]
=
audioUrl
;
this
.
save
();
}
async
generateTTS
(
sentence
:
string
):
Promise
<
string
>
{
const
commonPostMessageWithCallback
=
(
window
as
any
).
commonPostMessageWithCallback
;
if
(
typeof
commonPostMessageWithCallback
!==
'
function
'
)
{
throw
new
Error
(
'
通信方法不可用
'
);
}
return
new
Promise
<
string
>
((
resolve
,
reject
)
=>
{
commonPostMessageWithCallback
(
{
action
:
'
generateTTS
'
,
data
:
sentence
},
(
res
:
string
|
object
)
=>
{
const
resData
=
typeof
res
===
'
string
'
?
JSON
.
parse
(
res
)
:
res
;
if
(
resData
.
msg
==
'
success
'
&&
resData
.
data
)
{
resolve
(
resData
.
data
as
unknown
as
string
);
}
else
{
reject
(
'
音频生成失败
'
);
}
}
);
}).
catch
(()
=>
{
throw
new
Error
(
'
音频生成失败
'
);
});
}
ngOnInit
()
{
ngOnInit
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment