Merge branch 'main' of https://gitea.joylink.club/joylink/godot-psd-training into main
This commit is contained in:
commit
ed46c584d4
BIN
Assets/training_speech/sd.mp3
Normal file
BIN
Assets/training_speech/sd.mp3
Normal file
Binary file not shown.
19
Assets/training_speech/sd.mp3.import
Normal file
19
Assets/training_speech/sd.mp3.import
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="mp3"
|
||||||
|
type="AudioStreamMP3"
|
||||||
|
uid="uid://dvvpoqb8umdjy"
|
||||||
|
path="res://.godot/imported/sd.mp3-c6dc8a540e4c3c58e60586436e316423.mp3str"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/training_speech/sd.mp3"
|
||||||
|
dest_files=["res://.godot/imported/sd.mp3-c6dc8a540e4c3c58e60586436e316423.mp3str"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
BIN
Assets/training_speech/xt_pslgbztmwx.mp3
Normal file
BIN
Assets/training_speech/xt_pslgbztmwx.mp3
Normal file
Binary file not shown.
19
Assets/training_speech/xt_pslgbztmwx.mp3.import
Normal file
19
Assets/training_speech/xt_pslgbztmwx.mp3.import
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="mp3"
|
||||||
|
type="AudioStreamMP3"
|
||||||
|
uid="uid://iqr672ekex01"
|
||||||
|
path="res://.godot/imported/xt_pslgbztmwx.mp3-c340c6f2fdc9b84c839f54346780b458.mp3str"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/training_speech/xt_pslgbztmwx.mp3"
|
||||||
|
dest_files=["res://.godot/imported/xt_pslgbztmwx.mp3-c340c6f2fdc9b84c839f54346780b458.mp3str"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
BIN
Assets/training_speech/xt_pslibpkmwx.mp3
Normal file
BIN
Assets/training_speech/xt_pslibpkmwx.mp3
Normal file
Binary file not shown.
19
Assets/training_speech/xt_pslibpkmwx.mp3.import
Normal file
19
Assets/training_speech/xt_pslibpkmwx.mp3.import
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="mp3"
|
||||||
|
type="AudioStreamMP3"
|
||||||
|
uid="uid://op4mbi1lemrb"
|
||||||
|
path="res://.godot/imported/xt_pslibpkmwx.mp3-165b8ea64f29779308cdddb6c9efb934.mp3str"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/training_speech/xt_pslibpkmwx.mp3"
|
||||||
|
dest_files=["res://.godot/imported/xt_pslibpkmwx.mp3-165b8ea64f29779308cdddb6c9efb934.mp3str"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
BIN
Assets/training_speech/zby_ztmjczc.mp3
Normal file
BIN
Assets/training_speech/zby_ztmjczc.mp3
Normal file
Binary file not shown.
19
Assets/training_speech/zby_ztmjczc.mp3.import
Normal file
19
Assets/training_speech/zby_ztmjczc.mp3.import
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="mp3"
|
||||||
|
type="AudioStreamMP3"
|
||||||
|
uid="uid://dr1m5h02s45jf"
|
||||||
|
path="res://.godot/imported/zby_ztmjczc.mp3-849bbce90b59ebabfadd754a0ccf691a.mp3str"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/training_speech/zby_ztmjczc.mp3"
|
||||||
|
dest_files=["res://.godot/imported/zby_ztmjczc.mp3-849bbce90b59ebabfadd754a0ccf691a.mp3str"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
BIN
Assets/training_speech/zbzz_ckcjwb.mp3
Normal file
BIN
Assets/training_speech/zbzz_ckcjwb.mp3
Normal file
Binary file not shown.
19
Assets/training_speech/zbzz_ckcjwb.mp3.import
Normal file
19
Assets/training_speech/zbzz_ckcjwb.mp3.import
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="mp3"
|
||||||
|
type="AudioStreamMP3"
|
||||||
|
uid="uid://b5wej2w00ttnj"
|
||||||
|
path="res://.godot/imported/zbzz_ckcjwb.mp3-3c85dcaed29528587c7e0c8e32ccee6b.mp3str"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/training_speech/zbzz_ckcjwb.mp3"
|
||||||
|
dest_files=["res://.godot/imported/zbzz_ckcjwb.mp3-3c85dcaed29528587c7e0c8e32ccee6b.mp3str"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
BIN
Assets/training_speech/zlgzmhfzc.mp3
Normal file
BIN
Assets/training_speech/zlgzmhfzc.mp3
Normal file
Binary file not shown.
19
Assets/training_speech/zlgzmhfzc.mp3.import
Normal file
19
Assets/training_speech/zlgzmhfzc.mp3.import
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="mp3"
|
||||||
|
type="AudioStreamMP3"
|
||||||
|
uid="uid://bv1xfsb4450r1"
|
||||||
|
path="res://.godot/imported/zlgzmhfzc.mp3-02c91e6200e7ec22dcd1900223f9e0da.mp3str"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/training_speech/zlgzmhfzc.mp3"
|
||||||
|
dest_files=["res://.godot/imported/zlgzmhfzc.mp3-02c91e6200e7ec22dcd1900223f9e0da.mp3str"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
@ -1,7 +1,9 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var effect
|
## 录音效果器
|
||||||
var recording: AudioStreamWAV
|
var effect: AudioEffectRecord
|
||||||
|
## 录音捕获效果器(用于判断录音音量)
|
||||||
|
var capture: AudioEffectCapture
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
@ -10,17 +12,65 @@ func _ready():
|
|||||||
# And use it to retrieve its first effect, which has been defined
|
# And use it to retrieve its first effect, which has been defined
|
||||||
# as an "AudioEffectRecord" resource.
|
# as an "AudioEffectRecord" resource.
|
||||||
effect = AudioServer.get_bus_effect(idx, 0)
|
effect = AudioServer.get_bus_effect(idx, 0)
|
||||||
|
capture = AudioServer.get_bus_effect(idx, 1)
|
||||||
|
|
||||||
|
## 启动录音
|
||||||
func _on_psl_button_pressed():
|
func startRecord():
|
||||||
if effect.is_recording_active():
|
if not effect.is_recording_active():
|
||||||
recording = effect.get_recording()
|
|
||||||
print(recording.data.size())
|
|
||||||
effect.set_recording_active(false)
|
|
||||||
$AudioStreamRecord.stop()
|
|
||||||
$AudioStreamPlayer.stream = recording
|
|
||||||
$AudioStreamPlayer.play()
|
|
||||||
else:
|
|
||||||
$AudioStreamRecord.play()
|
|
||||||
effect.set_recording_active(true)
|
effect.set_recording_active(true)
|
||||||
|
|
||||||
|
|
||||||
|
## 停止录音
|
||||||
|
func stopRecord():
|
||||||
|
if effect.is_recording_active():
|
||||||
|
effect.set_recording_active(false)
|
||||||
|
|
||||||
|
var audio_sd = preload("res://Assets/training_speech/sd.mp3")
|
||||||
|
var audio_zlgzmhfzc = preload("res://Assets/training_speech/zlgzmhfzc.mp3")
|
||||||
|
|
||||||
|
|
||||||
|
## 播放回复
|
||||||
|
## PS: 是协程函数,外部可以await
|
||||||
|
func play_reply(reply):
|
||||||
|
stopRecord()
|
||||||
|
assert(reply is AudioStream, "reply不是音频资源")
|
||||||
|
## 确保不循环播放
|
||||||
|
if reply is AudioStreamMP3:
|
||||||
|
reply.loop = false
|
||||||
|
if reply is AudioStreamOggVorbis:
|
||||||
|
reply.loop = false
|
||||||
|
if reply is AudioStreamWAV:
|
||||||
|
reply.loop_mode = AudioStreamWAV.LOOP_DISABLED
|
||||||
|
$AudioStreamPlayer.stream = reply
|
||||||
|
$AudioStreamPlayer.play()
|
||||||
|
await $AudioStreamPlayer.finished
|
||||||
|
|
||||||
|
## 录音并语音识别检查
|
||||||
|
## PS: 是协程函数,外部如果关心结果需await
|
||||||
|
func speech_record_check(keywords: Array[String]):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _on_timer_timeout():
|
||||||
|
if effect.is_recording_active():
|
||||||
|
print(capture.get_buffer_length_frames(), ", ", capture.get_discarded_frames(), ", ", capture.get_frames_available())
|
||||||
|
var buf = capture.get_buffer(capture.get_frames_available())
|
||||||
|
for vec in buf:
|
||||||
|
if vec.x > 0.1 or vec.y > 0.1:
|
||||||
|
print("Left channel volume = ", vec.x, ", Right volume = ", vec.y)
|
||||||
|
#if effect.is_recording_active():
|
||||||
|
#recording = effect.get_recording()
|
||||||
|
#print(recording.data.size(), ", ", recording.format, ", ", recording.loop_mode, ", ", recording.get_length())
|
||||||
|
#stopRecord()
|
||||||
|
#var player = AudioStreamPlayer.new()
|
||||||
|
#add_child(player)
|
||||||
|
#player.stream = recording
|
||||||
|
#player.play()
|
||||||
|
#player.finished.connect( _on_audio_play_finished.bind(player))
|
||||||
|
#startRecord()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_audio_play_finished(player):
|
||||||
|
print(player, "播放完成")
|
||||||
|
player.stop()
|
||||||
|
player.queue_free()
|
||||||
|
pass
|
||||||
|
@ -9,6 +9,14 @@ script = ExtResource("1_73l6l")
|
|||||||
|
|
||||||
[node name="AudioStreamRecord" type="AudioStreamPlayer" parent="."]
|
[node name="AudioStreamRecord" type="AudioStreamPlayer" parent="."]
|
||||||
stream = SubResource("AudioStreamMicrophone_e60f1")
|
stream = SubResource("AudioStreamMicrophone_e60f1")
|
||||||
|
autoplay = true
|
||||||
bus = &"Record"
|
bus = &"Record"
|
||||||
|
|
||||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||||
|
autoplay = true
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
wait_time = 0.2
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://bsr40ogx2e2ir" path="res://UI/station_keys/jjtc_key_control.tscn" id="2_cndsv"]
|
[ext_resource type="PackedScene" uid="uid://bsr40ogx2e2ir" path="res://UI/station_keys/jjtc_key_control.tscn" id="2_cndsv"]
|
||||||
[ext_resource type="FontFile" uid="uid://bkbpyidjguavf" path="res://Assets/FeiHuaSongTi-2.ttf" id="2_mlqh2"]
|
[ext_resource type="FontFile" uid="uid://bkbpyidjguavf" path="res://Assets/FeiHuaSongTi-2.ttf" id="2_mlqh2"]
|
||||||
[ext_resource type="PackedScene" uid="uid://biwdpy5pifxgi" path="res://UI/station_keys/lcb_key_control.tscn" id="2_xelwb"]
|
[ext_resource type="PackedScene" uid="uid://biwdpy5pifxgi" path="res://UI/station_keys/lcb_key_control.tscn" id="2_xelwb"]
|
||||||
[ext_resource type="PackedScene" path="res://UI/station_keys/hsjc_key_control.tscn" id="9_q6qly"]
|
[ext_resource type="PackedScene" uid="uid://blixp06e6vnoe" path="res://UI/station_keys/hsjc_key_control.tscn" id="9_q6qly"]
|
||||||
[ext_resource type="AudioStream" uid="uid://di5nwer0mdafr" path="res://Assets/music/箭头提示音.mp3" id="10_cspe3"]
|
[ext_resource type="AudioStream" uid="uid://di5nwer0mdafr" path="res://Assets/music/箭头提示音.mp3" id="10_cspe3"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1w22c"]
|
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1w22c"]
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
[gd_resource type="AudioBusLayout" load_steps=2 format=3 uid="uid://b4m2yc5k0re6f"]
|
[gd_resource type="AudioBusLayout" load_steps=3 format=3 uid="uid://b4m2yc5k0re6f"]
|
||||||
|
|
||||||
[sub_resource type="AudioEffectRecord" id="AudioEffectRecord_bjx8q"]
|
[sub_resource type="AudioEffectRecord" id="AudioEffectRecord_bjx8q"]
|
||||||
resource_name = "Record"
|
resource_name = "Record"
|
||||||
|
|
||||||
|
[sub_resource type="AudioEffectCapture" id="AudioEffectCapture_fxogc"]
|
||||||
|
resource_name = "Capture"
|
||||||
|
buffer_length = 1.0
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
bus/1/name = &"Record"
|
bus/1/name = &"Record"
|
||||||
bus/1/solo = false
|
bus/1/solo = false
|
||||||
@ -12,3 +16,5 @@ bus/1/volume_db = 0.0
|
|||||||
bus/1/send = &"Master"
|
bus/1/send = &"Master"
|
||||||
bus/1/effect/0/effect = SubResource("AudioEffectRecord_bjx8q")
|
bus/1/effect/0/effect = SubResource("AudioEffectRecord_bjx8q")
|
||||||
bus/1/effect/0/enabled = true
|
bus/1/effect/0/enabled = true
|
||||||
|
bus/1/effect/1/effect = SubResource("AudioEffectCapture_fxogc")
|
||||||
|
bus/1/effect/1/enabled = true
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
[preset.0]
|
[preset.0]
|
||||||
|
|
||||||
name="station_keys"
|
name="Web"
|
||||||
platform="Web"
|
platform="Web"
|
||||||
runnable=false
|
runnable=true
|
||||||
dedicated_server=false
|
dedicated_server=false
|
||||||
custom_features=""
|
custom_features=""
|
||||||
export_filter="exclude"
|
export_filter="exclude"
|
||||||
@ -22,49 +22,7 @@ custom_template/release=""
|
|||||||
variant/extensions_support=false
|
variant/extensions_support=false
|
||||||
vram_texture_compression/for_desktop=true
|
vram_texture_compression/for_desktop=true
|
||||||
vram_texture_compression/for_mobile=false
|
vram_texture_compression/for_mobile=false
|
||||||
html/export_icon=true
|
html/export_icon=false
|
||||||
html/custom_html_shell=""
|
|
||||||
html/head_include="<style>
|
|
||||||
body {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
</style>"
|
|
||||||
html/canvas_resize_policy=2
|
|
||||||
html/focus_canvas_on_start=true
|
|
||||||
html/experimental_virtual_keyboard=false
|
|
||||||
progressive_web_app/enabled=false
|
|
||||||
progressive_web_app/offline_page=""
|
|
||||||
progressive_web_app/display=1
|
|
||||||
progressive_web_app/orientation=0
|
|
||||||
progressive_web_app/icon_144x144=""
|
|
||||||
progressive_web_app/icon_180x180=""
|
|
||||||
progressive_web_app/icon_512x512=""
|
|
||||||
progressive_web_app/background_color=Color(0, 0, 0, 1)
|
|
||||||
|
|
||||||
[preset.1]
|
|
||||||
|
|
||||||
name="Web"
|
|
||||||
platform="Web"
|
|
||||||
runnable=true
|
|
||||||
dedicated_server=false
|
|
||||||
custom_features=""
|
|
||||||
export_filter="all_resources"
|
|
||||||
include_filter=""
|
|
||||||
exclude_filter=""
|
|
||||||
export_path="../export/total.html"
|
|
||||||
encryption_include_filters=""
|
|
||||||
encryption_exclude_filters=""
|
|
||||||
encrypt_pck=false
|
|
||||||
encrypt_directory=false
|
|
||||||
|
|
||||||
[preset.1.options]
|
|
||||||
|
|
||||||
custom_template/debug=""
|
|
||||||
custom_template/release=""
|
|
||||||
variant/extensions_support=false
|
|
||||||
vram_texture_compression/for_desktop=true
|
|
||||||
vram_texture_compression/for_mobile=false
|
|
||||||
html/export_icon=true
|
|
||||||
html/custom_html_shell=""
|
html/custom_html_shell=""
|
||||||
html/head_include=""
|
html/head_include=""
|
||||||
html/canvas_resize_policy=2
|
html/canvas_resize_policy=2
|
||||||
|
@ -5,10 +5,16 @@ extends Node
|
|||||||
## 场景描述
|
## 场景描述
|
||||||
@export var trainingDesc: String = "场景描述"
|
@export var trainingDesc: String = "场景描述"
|
||||||
|
|
||||||
|
var a_sd = preload("res://Assets/training_speech/sd.mp3")
|
||||||
|
var a_xt_pslgbztmwx = preload("res://Assets/training_speech/xt_pslgbztmwx.mp3")
|
||||||
|
var a_zby_ztmjczc = preload("res://Assets/training_speech/zby_ztmjczc.mp3")
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
$TrainingDescDialog.title = trainingName
|
$TrainingDescDialog.title = trainingName
|
||||||
$TrainingDescDialog.updateSceneDesc(trainingDesc)
|
$TrainingDescDialog.updateSceneDesc(trainingDesc)
|
||||||
|
|
||||||
|
|
||||||
func _on_training_desc_dialog_start_training():
|
func _on_training_desc_dialog_start_training():
|
||||||
pass # Replace with function body.
|
await $VoiceCommunication.play_reply(a_xt_pslgbztmwx)
|
||||||
|
await $VoiceCommunication.play_reply(a_zby_ztmjczc)
|
||||||
|
await $VoiceCommunication.play_reply(a_sd)
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://dvsauaycyah6j"]
|
[gd_scene load_steps=4 format=3 uid="uid://dvsauaycyah6j"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://trainings/training1.gd" id="1_71wgx"]
|
[ext_resource type="Script" path="res://trainings/training1.gd" id="1_71wgx"]
|
||||||
[ext_resource type="PackedScene" uid="uid://qh8b3g6n3k2u" path="res://trainings/training_desc_dialog.tscn" id="2_oc00d"]
|
[ext_resource type="PackedScene" uid="uid://qh8b3g6n3k2u" path="res://trainings/training_desc_dialog.tscn" id="2_oc00d"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://6lortgihx5jy" path="res://Communication/voice_communication.tscn" id="3_ceo1a"]
|
||||||
|
|
||||||
[node name="Training1" type="Node"]
|
[node name="Training1" type="Node"]
|
||||||
script = ExtResource("1_71wgx")
|
script = ExtResource("1_71wgx")
|
||||||
@ -11,4 +12,6 @@ trainingDesc = "列车关门作业,突发单个站台门未正常关闭。"
|
|||||||
[node name="TrainingDescDialog" parent="." instance=ExtResource("2_oc00d")]
|
[node name="TrainingDescDialog" parent="." instance=ExtResource("2_oc00d")]
|
||||||
size = Vector2i(400, 300)
|
size = Vector2i(400, 300)
|
||||||
|
|
||||||
|
[node name="VoiceCommunication" parent="." instance=ExtResource("3_ceo1a")]
|
||||||
|
|
||||||
[connection signal="StartTraining" from="TrainingDescDialog" to="." method="_on_training_desc_dialog_start_training"]
|
[connection signal="StartTraining" from="TrainingDescDialog" to="." method="_on_training_desc_dialog_start_training"]
|
||||||
|
Loading…
Reference in New Issue
Block a user