-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.html
797 lines (637 loc) · 29.8 KB
/
player.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Bato Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<!-- Facebook and Twitter integration -->
<meta property="og:title" content=""/>
<meta property="og:image" content=""/>
<meta property="og:url" content=""/>
<meta property="og:site_name" content=""/>
<meta property="og:description" content=""/>
<meta name="twitter:title" content="" />
<meta name="twitter:image" content="" />
<meta name="twitter:url" content="" />
<meta name="twitter:card" content="" />
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="shortcut icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Karla:400,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Playfair+Display:400,400i,700" rel="stylesheet">
<!-- Animate.css -->
<link rel="stylesheet" href="css/animate.css">
<!-- Icomoon Icon Fonts-->
<link rel="stylesheet" href="css/icomoon.css">
<!-- Bootstrap -->
<link rel="stylesheet" href="css/bootstrap.css">
<!-- Owl Carousel -->
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">
<!-- Magnific Popup -->
<link rel="stylesheet" href="css/magnific-popup.css">
<link rel="stylesheet" href="css/style.css">
<!-- Modernizr JS -->
<script src="js/modernizr-2.6.2.min.js"></script>
<!-- FOR IE9 below -->
<!--[if lt IE 9]>
<script src="js/respond.min.js"></script>
<![endif]-->
<style>
body{
background-color: ivory;
}
.yt_video_list{
box-sizing: border-box;
margin: 30px;
margin-left: 10px;
padding: 30px;
width: 98%;
height: auto;
border: 1px solid #F9CE00;
background: transparent;
overflow: hidden;
vertical-align: middle;
display: inline-block;
position:relative;
}
@import 'https://fonts.googleapis.com/css?family=Roboto';
@import url('https://fonts.googleapis.com/css?family=Do+Hyeon|Noto+Sans+KR&display=swap');
h1 {
margin: 20px auto 0;
font-size: 20px;
font-weight: 700;
text-align: center;
}
.youtube {
box-sizing: border-box;
margin: 20px auto;
width: 650px;
border: 1px solid #ddd;
background: #f5f5f5;
font-family: 'Roboto';
font-size: 14px;
overflow: hidden;
}
iframe {
display: block;
width: 960px;
height: 540px;
}
#music_player_i{
width: 90px;
height: 60px;
}
/* 유튜브 감싸는 div */
#player_wrapper{
/* border: 1px solid #ff9999; */
/* 중앙 정렬 */
width: 1350px; margin: 30px auto;
/* 수평 레이아웃 구성 */
overflow: hidden;
}
/* 플레이어 section *플레이어 div를 담는 공간 */
#player_wrapper > #player_section{
/* 왼쪽에 붙이기 *자식이 float 속성 사용시 >> 부모 overflow:hidden */
width:1000px; float: left;
/* 구분하기 편하기 위해서 보더 속성 추후에 삭제 */
/* border: 1px solid #ff9999; */
}
/* 챗봇 aside */
#player_wrapper > #chatBot_aside {
width: 340px;
float: right;
background-color: #ffc600;
border-radius: 8px;
/* padding-right: 10px; */
/* margin-top: 20px; */
margin-right: 8px;
}
/* 챗봇 들어갈 공간 */
#player_wrapper > #chatBot_aside > #chatBot_div{
width: 335px; margin: 4px auto;
height: 486px;
/* height: 186px; */
overflow-y: auto;
border: 2px solid ivory;
border-left: thick solid #d9eaf3;
border-radius: 8px;
box-shadow:4px 4px 0 rgba(0,0,0,0.1);
background: -webkit-gradient(linear, 0 0, 0 100%, from(#d9eaf3), color-stop(4%, #fff)) 0 4px;
/* 챗봇 배경에 줄 간격 조절 코드 rem */
background-size: 100% 1.7rem;
}
/* 챗봇 스크롤바 디자인 */
#chatBot_div::-webkit-scrollbar{
/* 스크롤바 너비 */
width: 15px;
}
#chatBot_div::-webkit-scrollbar-thumb{
/* 스크롤바 너비 */
width: 15px;
/* 스크롤바 둥글게 */
border-radius: 8px;
/* 스크롤바 색깔 */
background-color: #ffc600;
}
#chatBot_div::-webkit-scrollbar-track{
/* 스크롤바 너비 */
width: 15px;
/* 스크롤바 배경 색깔 */
background-color: ivory;
}
/* 플레이어 div */
#player_section > div.player_div{
margin-bottom: 10px;
padding: 20px;
/* 구분하기 편하기 위해서 보더 속성 추후에 삭제 */
/* border: 3px solid teal; */
}
#player_section > div#player{
margin-bottom: 10px;
padding: 20px;
/* 구분하기 편하기 위해서 보더 속성 추후에 삭제 */
/* border: 3px solid teal; */
}
/* 탭 모양 구성 */
section.chatBot_title{
overflow: hidden;
border: 1px solid ivory;
border-radius: 8px;
box-shadow: 4px 4px 0 rgba(0,0,0,0.1);
}
section.chatBot_title > label{
font-family: 'Do Hyeon' ;
/* 수평정렬 */
display: block; float: left;
/* 크기 & 글자 위치 */
width: 400px; height:40px;
/* 글자는 수직 정렬을 line-height 와 height 맞춰 줌 */
line-height: 40px;
/* 글자 수평 정렬 */
text-align: center;
/* 배경 */
background: #ffc600;
color: ivory;
/* AI 챗봇 Yori 텍스트랑 담고 있는 상자랑 크기 맞춰주는 코드? */
box-sizing: border-box;
}
.chatBot_wrapper{
margin: 0 auto;
overflow: hidden;
}
/* 챗봇 aside 속 말풍선 클래스 (ex: 명령어, 음악, 타이머) */
p.tab_item{
width:250px; margin-left: 2px;
box-sizing: border-box;
border: 3px solid #ff9999;
border-radius: 8px;
padding: 0 2px;
background-color: ivory;
}
div.tab_item {
width:250px; margin: 0 auto;
margin-left: 6px;
box-sizing: border-box;
border: 3px solid teal;
border-radius: 8px;
margin: 10px auto;
padding: 0 2px;
background-color: ivory;
}
span.tab_item #timerTxt {
width:250px; margin-left: 6px;
box-sizing: border-box;
border: 3px solid #ff9999;
border-radius: 8px;
padding: 0 2px;
background-color: ivory;
}
img.tab_item{
box-sizing: border-box;
border-radius: 8px;
margin: 4px 8px;
box-shadow: 4px 4px 0 rgba(0,0,0,0.1);
}
span#music_player {
width:250px; margin-left: 6px;
box-sizing: border-box;
border: 3px solid #ff9999;
border-radius: 8px;
padding: 0 2px;
background-color: ivory;
}
.col-md-12_1 {
width: 20%;
}
</style>
</head>
<body>
<nav id="colorlib-main-nav" role="navigation">
<a href="#" class="js-colorlib-nav-toggle colorlib-nav-toggle active"><i></i></a>
<div class="js-fullheight colorlib-table">
<div class="colorlib-table-cell js-fullheight">
<div class="row">
<div class="col-md-12_1">
<div class="form-group">
<h3>LogIn</h3>
<input type="text" name="login_id" class="form-control" placeholder="ID">
<input type="password" name="login_pw" class="form-control" placeholder="PW">
<input type="submit" value="LOGIN" class="btn1 btn-primary btn-submit1"><input type="submit" value="JOIN" class="btn1 btn-primary1 btn-submit2" onclick="location.href='join.html'">
<!-- <button type="submit" class="btn btn-primary"><i class="icon-search3"></i></button> -->
</div>
</div>
</div>
<div class="row">
<div class="col-md-12_1">
<ul>
<li class="active"><a href="index.html">Home</a></li>
<!-- <li><a href="login.html">Login</a></li> -->
<!-- <li><a href="join.html">Join</a></li> -->
<li><a href="about.html">About</a></li>
<!-- <li><a href="contact.html">Contact</a></li> -->
</ul>
</div>
</div>
</div>
</div>
</nav>
<div id="colorlib-page">
<header>
<div class="container">
<div class="row">
<div class="col-md-12_1">
<div class="colorlib-navbar-brand">
<a class="colorlib-logo" href="index.html">YORI</a>
</div>
</div>
<a href="#" class="js-colorlib-nav-toggle colorlib-nav-toggle"><i></i></a>
</div>
</div>
</div>
</header>
<div class="text_search">
<input type = "text" class="list_search" placeholder="오늘 뭐 먹지?" name="search" id="query">
<button id="query-btn" class="btn btn-primary"><i class="icon-search3"></i></button>
</div>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<!-- 플레이어 감싸는 div -->
<div id = "player_wrapper">
<section id = "player_section">
<!-- 플레이어 div -->
<div class = player_div id="player">
<!-- <iframe width="960" height="600"
src="https://www.youtube.com/embed/SscID7HH3AY"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe> -->
<!-- 플레이어 닫히는 부분 -->
</div>
</section>
<!-- 챗봇 aside -->
<aside id = "chatBot_aside">
<!-- 탭 버튼 들어오는 자리 -->
<section class = "chatBot_title">
<label for = "chatBot_title"><font size="5em" color="white">
요리와 대화하기</font></label>
</section>
<!-- 챗봇 div 넣을 자리 -->
<div id = "chatBot_div" contenteditable>
<!-- 명령어 & 영상 & 타이머 -->
<!-- p >> 명령어 // div >> 컨텐츠 -->
<!-- 추가되면 자동으로 스크롤 다운 -->
<div class="chatBot_wrapper">
<span class="chatBot_wrapper">
<img src = "images/chatBot_Icon.png" class = "tab_item">
<span class = "tab_item">
안녕하세요! 요리입니다!
</span>
</span>
</div>
</div>
</aside>
<!-- wrapper 닫히는 부분 -->
</div>
<footer>
<div id="footer">
<div class="container">
<div class="row">
<div class="col-md-4 col-pb-sm text-center">
<div class="row">
<div class="col-md-10">
<h2>Office</h2>
<p>291 South 21th Street, <br> Suite 721 New York NY 10016</p>
</div>
</div>
</div>
<div class="col-md-4 col-pb-sm text-center">
<h2>Get in Touch</h2>
<p><a href="#">[email protected]</a></p>
</div>
<div class="col-md-4 col-pb-sm text-center">
<h2>Social</h2>
<p class="colorlib-social-icons">
<a href="#"><i class="icon-facebook4"></i></a>
<a href="#"><i class="icon-twitter3"></i></a>
<a href="#"><i class="icon-googleplus"></i></a>
<a href="#"><i class="icon-dribbble2"></i></a>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12_1 text-center">
<p>
<span class="block"><!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
Copyright ©<script>document.write(new Date().getFullYear());</script> All rights reserved | This template is made with <i class="icon-heart" aria-hidden="true"></i> by <a href="https://colorlib.com" target="_blank">Colorlib</a>
<!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. --><br></span>
<span class="block">Demo Images: <a href="http://unsplash.co/" target="_blank">Unsplash</a></span>
</p>
</div>
</div>
</div>
</div>
</footer>o
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- jQuery Easing -->
<script src="js/jquery.easing.1.3.js"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- Waypoints -->
<script src="js/jquery.waypoints.min.js"></script>
<!-- Owl Carousel -->
<script src="js/owl.carousel.min.js"></script>
<!-- Magnific Popup -->
<script src="js/jquery.magnific-popup.min.js"></script>
<script src="js/magnific-popup-options.js"></script>
<!-- Main JS (Do not remove) -->
<script src="js/main.js"></script>
<script type="text/javascript"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script>
var index = location.href.search('=');
var id = location.href.slice(index + 1);
var getVideoId = localStorage.getItem(id);
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '360',
width: '640',
videoId: getVideoId,
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
// if (event.data == YT.PlayerState.PLAYING ) {
// // setTimeout(stopVideo, 6000);
// // done = true;
// }
}
$('button').on('click', function () {
var $ele_attr = $(this).attr('class');
if ($ele_attr === 'yt_pause') {
player.pauseVideo();
} else if ($ele_attr === 'yt_play') {
player.playVideo();
}
});
</script>
<script>
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; // api 불러오는 코드
const recognition = new SpeechRecognition(); //api 호출
recognition.interimResults= false; // 말하는 과정까지 띄워줌 / false = 말 끝나면 띄워줌
recognition.lang = 'ko-KR'; // 언어 설정
let p = document.createElement('p'); // 하얀 박스
const words = document.querySelector('.words'); // 음성을 글자로
// words.appendChild(p); // 음성을 박스에 띄워주는 코드
recognition.addEventListener('result', voiceRecording =>{
const transcript = Array.from(voiceRecording.results)
.map(result => result[0])
.map(result => result.transcript)
.join('');
p.textContent = transcript; // transcript = 사용자 음성 / 사용자 음성을 하얀 박스에 띄움
if (voiceRecording.results[0].isFinal) { // 말이 끝나면 새롭게 문단을 나눠주는 코드
// p=document.createElement('p'); // transcript를 띄워주는 코드
// words.appendChild(p);
}
console.log(transcript);
// 자동 스크롤바 다운 기능 구현하기 위해 변수 설정
var chatBot_div_scroller = document.getElementById("chatBot_div");
// 변수에 함수 입혀서 내용 추가되면 자동으로 스크롤 다운
chatBot_div_scroller.scrollTop = chatBot_div_scroller.scrollHeight;
if (transcript.includes('요리') || transcript.includes('유리')){ // 특정 문자열 포함 여부 확인
// systemMessage.innerHTML = '요리 불렀어?'; // 제일 위 글자 바뀌는 코드
text_to_speech("네 ?즐거운 요리시간이네요"); // 인공 음성
}
else if (transcript.includes('틀어') || transcript.includes('재생')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'영상을 재생할게요'+'</span></span></div>');
player.playVideo();
text_to_speech("영상을 재생합니다! ");
}
else if (transcript.includes('멈춰') || transcript.includes('잠시')|| transcript.includes('잠깐만')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'영상을 멈출게요!'+'</span></span></div>');
player.pauseVideo();
text_to_speech("멈춰 줄게요!");
}
else if (transcript.includes('줄여줘') || transcript.includes('작게')|| transcript.includes('줄여')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'소리를 줄일게요!'+'</span></span></div>');
player.setVolume(player.getVolume()-20);
text_to_speech("소리를 줄일게요. ");
}
else if (transcript.includes('소리 크게') || transcript.includes('크게 말해줘')|| transcript.includes('크게 말해')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'소리를 크게해줄게요!'+'</span></span></div>');
player.setVolume(player.getVolume()+20);
text_to_speech("소리를 크게해줄게요. ");
}
else if (transcript.includes('조용히 해') || transcript.includes('음소거')|| transcript.includes('쉿')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'소리를 꺼줄게요!'+'</span></span></div>');
player.mute();
text_to_speech("소리를 꺼줄게요. ");
}
else if (transcript.includes('최대') || transcript.includes('제일 크게')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'제일 큰 소리로 재생해줄게요!'+'</span></span></div>');
player.setVolume(100);
text_to_speech("제일 큰 소리로 재생해줄게요. ");
}
else if (transcript.includes('음소거 꺼줘') || transcript.includes('다시 소리')|| transcript.includes('소리 들려줘')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'소리를 다시 켜줄게요!'+'</span></span></div>');
player.unMute();
text_to_speech("소리를 켜줄게요. ");
}
else if (transcript.includes('천천히') || transcript.includes('느리게')|| transcript.includes('속도 줄여')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'영상 속도를 천천히 할게요!'+'</span></span></div>');
player.setPlaybackRate(player.getPlaybackRate()-0.5);
text_to_speech("영상 속도를 천천히 합니다. ");
}
else if (transcript.includes('원래대로') || transcript.includes('평소대로')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'영상 속도를 원래대로 해줄게요!'+'</span></span></div>');
player.setPlaybackRate(1);
text_to_speech("영상 속도를 원래대로 해줄게요 ");
}
else if (transcript.includes('빠르게') || transcript.includes('빨리 보여줘')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'영상을 속도를 빠르게 할게요!'+'</span></span></div>');
player.setPlaybackRate(player.getPlaybackRate()+0.5);
text_to_speech("영상 속도를 빠르게 합니다. ");
}
else if (transcript.includes('뒤로') || transcript.includes('한번 더')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'10초 전!'+'</span></span></div>');
player.seekTo(currentTime-10, true);
// text_to_speech("10초 전! ");
}
else if (transcript.includes('앞으로') || transcript.includes('스킵')){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'10초 후!'+'</span></span></div>');
player.seekTo(currentTime+10, true);
// text_to_speech("10초 후! ");
}
// //음악재생
// else if (transcript.includes('음악') || transcript.includes('노래') ){
// player.pauseVideo();
// $('#chatBot_div').append('<div class="chatBot_wrapper">'+
// '<span class="chatBot_wrapper">'+
// '<img src = "images/chatBot_Icon.png" class = "tab_item">'+
// '<span class = "tab_item">'+'음악을 틀어드릴게요!'+'</span></span></div>');
// var music = window.open('http://127.0.0.1:5500/0217/bato/musicplay_play.html',"music_name",
// "resizable", true);
// }
else if ( transcript.includes('1') || transcript.includes('1분') ){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'타이머 1분 설정!'+'</span></span></div>');
player.pauseVideo();
timerStart(1);
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/clock_icon.png" class = "tab_item">'+
'<span class = "tab_item"><span id="timerTxt"></span></span></span></div>');
// $('#chatBot_div').append('<p id="systemMessage" class = "tab_item">'+'' + '</p>');
// $('#chatBot_div').append('<div class="tab_item "><div id="timerTxt"></div></div>');
text_to_speech("타이머를 시작합니다. ");
}
else if ( transcript.includes('그만') || transcript.includes('정지') ){
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'타이머 정지!'+'</span></span></div>');
text_to_speech("타이머를 멈출게요.");
timerStop();
player.playVideo();
}
});
recognition.addEventListener('end', recognition.start); // 음성 인식이 끝나면 다시 시작하는 코드
recognition.start();
</script>
<script>
// 텍스트를 음성으로
function text_to_speech(txt) {
// Web Speech API - speech synthesis
if ('speechSynthesis' in window) {
// Synthesis support. Make your web apps talk!
console.log("음성합성을 지원하는 브라우저입니다.");
}
var systemVoice = new SpeechSynthesisUtterance();
var voices = window.speechSynthesis.getVoices();
//systemVoice.voice = voices[10]; // 두번째 부터 완전 외국인 발음이 됨. 사용하지 말것.
systemVoice.voiceURI = 'native';
systemVoice.volume = 1; // 0 to 1
systemVoice.rate = 0.9; // 0.1 to 10
//systemVoice.pitch = 2; //0 to 2
systemVoice.text = txt;
systemVoice.lang = 'ko-KR';
systemVoice.onend = function (e) {
if (isRecognizing == false) {
recognition.start();
}
console.log('Finished in ' + event.elapsedTime + ' seconds.');
};
window.speechSynthesis.speak(systemVoice);
}
var timerId;
var timerSec;
function timerStart(timeSc){
timerSec= timeSc*60;
timerId = setInterval(timer, 1000);
}
function timer() {
var min = Math.floor(timerSec / 60)
var sec = timerSec % 60;
var msg = (min < 10 ? "0" + min : min) + ":" + (sec < 10 ? "0" + sec : sec);
timerSec--;
if(timerSec==0){
console.log('타이머 중지.');
clearInterval(timerId);
player.playVideo();
$('#chatBot_div').append('<div class="chatBot_wrapper">'+
'<span class="chatBot_wrapper">'+
'<img src = "images/chatBot_Icon.png" class = "tab_item">'+
'<span class = "tab_item">'+'영상을 다시 시작합니다!'+'</span></span></div>');
text_to_speech("영상을 다시 시작합니다.");
}
document.getElementById("timerTxt").innerHTML = msg;
}
function timerStop(){
if(timerId != undefined){
console.log('타이머 중지.');
clearInterval(timerId);
}
};
</script>
</body>
</html>