Resemblyzer | python package to analyze and compare voices | Speech library

 by   resemble-ai Python Version: 0.1.1.dev0 License: Apache-2.0

kandi X-RAY | Resemblyzer Summary

Resemblyzer is a Python library typically used in Artificial Intelligence, Speech, Deep Learning, Tensorflow applications. Resemblyzer has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can install using 'pip install Resemblyzer' or download it from GitHub, PyPI.
Resemblyzer allows you to derive a high-level representation of a voice through a deep learning model (referred to as the voice encoder). Given an audio file of speech, it creates a summary vector of 256 values (an embedding, often shortened to "embed" in this repo) that summarizes the characteristics of the voice spoken. N.B.: this repo holds 100mb of audio data for demonstration purpose. To get the package alone, run pip install resemblyzer (python 3.5+ is required).
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        Resemblyzer has a medium active ecosystem.
                        summary
                        It has 2197 star(s) with 380 fork(s). There are 68 watchers for this library.
                        summary
                        It had no major release in the last 12 months.
                        summary
                        There are 33 open issues and 36 have been closed. On average issues are closed in 13 days. There are no pull requests.
                        summary
                        It has a neutral sentiment in the developer community.
                        summary
                        The latest version of Resemblyzer is 0.1.1.dev0
                        Resemblyzer Support
                          Best in #Speech
                            Average in #Speech
                            Resemblyzer Support
                              Best in #Speech
                                Average in #Speech

                                  kandi-Quality Quality

                                    summary
                                    Resemblyzer has 0 bugs and 0 code smells.
                                    Resemblyzer Quality
                                      Best in #Speech
                                        Average in #Speech
                                        Resemblyzer Quality
                                          Best in #Speech
                                            Average in #Speech

                                              kandi-Security Security

                                                summary
                                                Resemblyzer has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
                                                summary
                                                Resemblyzer code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                Resemblyzer Security
                                                  Best in #Speech
                                                    Average in #Speech
                                                    Resemblyzer Security
                                                      Best in #Speech
                                                        Average in #Speech

                                                          kandi-License License

                                                            summary
                                                            Resemblyzer is licensed under the Apache-2.0 License. This license is Permissive.
                                                            summary
                                                            Permissive licenses have the least restrictions, and you can use them in most projects.
                                                            Resemblyzer License
                                                              Best in #Speech
                                                                Average in #Speech
                                                                Resemblyzer License
                                                                  Best in #Speech
                                                                    Average in #Speech

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        Resemblyzer releases are available to install and integrate.
                                                                        summary
                                                                        Deployable package is available in PyPI.
                                                                        summary
                                                                        Build file is available. You can build the component from source.
                                                                        summary
                                                                        Installation instructions are not available. Examples and code snippets are available.
                                                                        summary
                                                                        Resemblyzer saves you 84 person hours of effort in developing the same functionality from scratch.
                                                                        summary
                                                                        It has 216 lines of code, 12 functions and 7 files.
                                                                        summary
                                                                        It has high code complexity. Code complexity directly impacts maintainability of the code.
                                                                        Resemblyzer Reuse
                                                                          Best in #Speech
                                                                            Average in #Speech
                                                                            Resemblyzer Reuse
                                                                              Best in #Speech
                                                                                Average in #Speech
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi has reviewed Resemblyzer and discovered the below as its top functions. This is intended to give you an instant insight into Resemblyzer implemented functionality, and help decide if they suit your requirements.
                                                                                  • Preprocess a wav file
                                                                                    • Trim the end of the audio waveform
                                                                                    • Normalize a wav
                                                                                  • Plot the diagization of the similarity plot
                                                                                    • Play a WAV file
                                                                                  • Embed the utterance of the utterance
                                                                                    • Computes the split utterances for two partial utterances
                                                                                  • Embed a list of speakers
                                                                                    • Embed the utterance of a given utterance
                                                                                  • Plot projections of speakers
                                                                                  • Plot similarity matrix
                                                                                  • Plot histogram of samples
                                                                                  Get all kandi verified functions for this library.
                                                                                  Get all kandi verified functions for this library.

                                                                                  Resemblyzer Key Features

                                                                                  A python package to analyze and compare voices with deep learning

                                                                                  Resemblyzer Examples and Code Snippets

                                                                                  No Code Snippets are available at this moment for Resemblyzer.
                                                                                  Community Discussions

                                                                                  Trending Discussions on Speech

                                                                                  Enable use of images from the local library on Kubernetes
                                                                                  chevron right
                                                                                  IndexError: tuple index out of range when I try to create an executable from a python script using auto-py-to-exe
                                                                                  chevron right
                                                                                  Google Actions Builder stops execution when selecting a visual item from a List
                                                                                  chevron right
                                                                                  How to use muti-language in 'gTTS' for single input line?
                                                                                  chevron right
                                                                                  Assigning True/False if a token is present in a data-frame
                                                                                  chevron right
                                                                                  speechSynthesis.getVoices (Web Speech API) doesn't show some of the locally installed voices
                                                                                  chevron right
                                                                                  Combining Object Detection with Text to Speech Code
                                                                                  chevron right
                                                                                  Yielding values from consecutive parallel parse functions via meta in Scrapy
                                                                                  chevron right
                                                                                  Rails. Puma stops working when instantiating a client of Google Cloud Text-to-Speech (Windows)
                                                                                  chevron right
                                                                                  R - Regular Expression to Extract Text Between Parentheses That Contain Keyword
                                                                                  chevron right

                                                                                  QUESTION

                                                                                  Enable use of images from the local library on Kubernetes
                                                                                  Asked 2022-Mar-20 at 13:23

                                                                                  I'm following a tutorial https://docs.openfaas.com/tutorials/first-python-function/,

                                                                                  currently, I have the right image

                                                                                  $ docker images | grep hello-openfaas
                                                                                  wm/hello-openfaas                                     latest                          bd08d01ce09b   34 minutes ago      65.2MB
                                                                                  $ faas-cli deploy -f ./hello-openfaas.yml 
                                                                                  Deploying: hello-openfaas.
                                                                                  WARNING! You are not using an encrypted connection to the gateway, consider using HTTPS.
                                                                                  
                                                                                  Deployed. 202 Accepted.
                                                                                  URL: http://IP:8099/function/hello-openfaas
                                                                                  

                                                                                  there is a step that forewarns me to do some setup(My case is I'm using Kubernetes and minikube and don't want to push to a remote container registry, I should enable the use of images from the local library on Kubernetes.), I see the hints

                                                                                  see the helm chart for how to set the ImagePullPolicy
                                                                                  

                                                                                  I'm not sure how to configure it correctly. the final result indicates I failed.

                                                                                  Unsurprisingly, I couldn't access the function service, I find some clues in https://docs.openfaas.com/deployment/troubleshooting/#openfaas-didnt-start which might help to diagnose the problem.

                                                                                  $ kubectl logs -n openfaas-fn deploy/hello-openfaas
                                                                                  Error from server (BadRequest): container "hello-openfaas" in pod "hello-openfaas-558f99477f-wd697" is waiting to start: trying and failing to pull image
                                                                                  
                                                                                  $ kubectl describe -n openfaas-fn deploy/hello-openfaas
                                                                                  Name:                   hello-openfaas
                                                                                  Namespace:              openfaas-fn
                                                                                  CreationTimestamp:      Wed, 16 Mar 2022 14:59:49 +0800
                                                                                  Labels:                 faas_function=hello-openfaas
                                                                                  Annotations:            deployment.kubernetes.io/revision: 1
                                                                                                          prometheus.io.scrape: false
                                                                                  Selector:               faas_function=hello-openfaas
                                                                                  Replicas:               1 desired | 1 updated | 1 total | 0 available | 1 unavailable
                                                                                  StrategyType:           RollingUpdate
                                                                                  MinReadySeconds:        0
                                                                                  RollingUpdateStrategy:  0 max unavailable, 1 max surge
                                                                                  Pod Template:
                                                                                    Labels:       faas_function=hello-openfaas
                                                                                    Annotations:  prometheus.io.scrape: false
                                                                                    Containers:
                                                                                     hello-openfaas:
                                                                                      Image:      wm/hello-openfaas:latest
                                                                                      Port:       8080/TCP
                                                                                      Host Port:  0/TCP
                                                                                      Liveness:   http-get http://:8080/_/health delay=2s timeout=1s period=2s #success=1 #failure=3
                                                                                      Readiness:  http-get http://:8080/_/health delay=2s timeout=1s period=2s #success=1 #failure=3
                                                                                      Environment:
                                                                                        fprocess:  python3 index.py
                                                                                      Mounts:      
                                                                                    Volumes:       
                                                                                  Conditions:
                                                                                    Type           Status  Reason
                                                                                    ----           ------  ------
                                                                                    Available      False   MinimumReplicasUnavailable
                                                                                    Progressing    False   ProgressDeadlineExceeded
                                                                                  OldReplicaSets:  
                                                                                  NewReplicaSet:   hello-openfaas-558f99477f (1/1 replicas created)
                                                                                  Events:
                                                                                    Type    Reason             Age   From                   Message
                                                                                    ----    ------             ----  ----                   -------
                                                                                    Normal  ScalingReplicaSet  29m   deployment-controller  Scaled up replica set hello-openfaas-558f99477f to 1
                                                                                  

                                                                                  hello-openfaas.yml

                                                                                  version: 1.0
                                                                                  provider:
                                                                                    name: openfaas
                                                                                    gateway: http://IP:8099
                                                                                  functions:
                                                                                    hello-openfaas:
                                                                                      lang: python3
                                                                                      handler: ./hello-openfaas
                                                                                      image: wm/hello-openfaas:latest
                                                                                      imagePullPolicy: Never
                                                                                  

                                                                                  I create a new project hello-openfaas2 to reproduce this error

                                                                                  $ faas-cli new --lang python3 hello-openfaas2 --prefix="wm"
                                                                                  Folder: hello-openfaas2 created.
                                                                                  # I add `imagePullPolicy: Never` to `hello-openfaas2.yml`
                                                                                  $ faas-cli build -f ./hello-openfaas2.yml 
                                                                                  $ faas-cli deploy -f ./hello-openfaas2.yml 
                                                                                  Deploying: hello-openfaas2.
                                                                                  WARNING! You are not using an encrypted connection to the gateway, consider using HTTPS.
                                                                                  
                                                                                  Deployed. 202 Accepted.
                                                                                  URL: http://192.168.1.3:8099/function/hello-openfaas2
                                                                                  
                                                                                  
                                                                                  $ kubectl logs -n openfaas-fn deploy/hello-openfaas2
                                                                                  Error from server (BadRequest): container "hello-openfaas2" in pod "hello-openfaas2-7c67488865-7d7vm" is waiting to start: image can't be pulled
                                                                                  
                                                                                  $ kubectl get pods --all-namespaces
                                                                                  NAMESPACE              NAME                                        READY   STATUS             RESTARTS         AGE
                                                                                  kube-system            coredns-64897985d-kp7vf                     1/1     Running            0                47h
                                                                                  ...
                                                                                  openfaas-fn            env-6c79f7b946-bzbtm                        1/1     Running            0                4h28m
                                                                                  openfaas-fn            figlet-54db496f88-957xl                     1/1     Running            0                18h
                                                                                  openfaas-fn            hello-openfaas-547857b9d6-z277c             0/1     ImagePullBackOff   0                127m
                                                                                  openfaas-fn            hello-openfaas-7b6946b4f9-hcvq4             0/1     ImagePullBackOff   0                165m
                                                                                  openfaas-fn            hello-openfaas2-7c67488865-qmrkl            0/1     ImagePullBackOff   0                13m
                                                                                  openfaas-fn            hello-openfaas3-65847b8b67-b94kd            0/1     ImagePullBackOff   0                97m
                                                                                  openfaas-fn            hello-python-554b464498-zxcdv               0/1     ErrImagePull       0                3h23m
                                                                                  openfaas-fn            hello-python-8698bc68bd-62gh9               0/1     ImagePullBackOff   0                3h25m
                                                                                  

                                                                                  from https://docs.openfaas.com/reference/yaml/, I know I put the imagePullPolicy in the wrong place, there is no such keyword in its schema.

                                                                                  I also tried eval $(minikube docker-env and still get the same error.

                                                                                  I've a feeling that faas-cli deploy can be replace by helm, they all mean to run the image(whether from remote or local) in Kubernetes cluster, then I can use helm chart to setup the pullPolicy there. Even though the detail is not still clear to me, This discovery inspires me.

                                                                                  So far, after eval $(minikube docker-env)

                                                                                  $ docker images
                                                                                  REPOSITORY                                TAG        IMAGE ID       CREATED             SIZE
                                                                                  wm/hello-openfaas2                        0.1        03c21bd96d5e   About an hour ago   65.2MB
                                                                                  python                                    3-alpine   69fba17b9bae   12 days ago         48.6MB
                                                                                  ghcr.io/openfaas/figlet                   latest     ca5eef0de441   2 weeks ago         14.8MB
                                                                                  ghcr.io/openfaas/alpine                   latest     35f3d4be6bb8   2 weeks ago         14.2MB
                                                                                  ghcr.io/openfaas/faas-netes               0.14.2     524b510505ec   3 weeks ago         77.3MB
                                                                                  k8s.gcr.io/kube-apiserver                 v1.23.3    f40be0088a83   7 weeks ago         135MB
                                                                                  k8s.gcr.io/kube-controller-manager        v1.23.3    b07520cd7ab7   7 weeks ago         125MB
                                                                                  k8s.gcr.io/kube-scheduler                 v1.23.3    99a3486be4f2   7 weeks ago         53.5MB
                                                                                  k8s.gcr.io/kube-proxy                     v1.23.3    9b7cc9982109   7 weeks ago         112MB
                                                                                  ghcr.io/openfaas/gateway                  0.21.3     ab4851262cd1   7 weeks ago         30.6MB
                                                                                  ghcr.io/openfaas/basic-auth               0.21.3     16e7168a17a3   7 weeks ago         14.3MB
                                                                                  k8s.gcr.io/etcd                           3.5.1-0    25f8c7f3da61   4 months ago        293MB
                                                                                  ghcr.io/openfaas/classic-watchdog         0.2.0      6f97aa96da81   4 months ago        8.18MB
                                                                                  k8s.gcr.io/coredns/coredns                v1.8.6     a4ca41631cc7   5 months ago        46.8MB
                                                                                  k8s.gcr.io/pause                          3.6        6270bb605e12   6 months ago        683kB
                                                                                  ghcr.io/openfaas/queue-worker             0.12.2     56e7216201bc   7 months ago        7.97MB
                                                                                  kubernetesui/dashboard                    v2.3.1     e1482a24335a   9 months ago        220MB
                                                                                  kubernetesui/metrics-scraper              v1.0.7     7801cfc6d5c0   9 months ago        34.4MB
                                                                                  nats-streaming                            0.22.0     12f2d32e0c9a   9 months ago        19.8MB
                                                                                  gcr.io/k8s-minikube/storage-provisioner   v5         6e38f40d628d   11 months ago       31.5MB
                                                                                  functions/markdown-render                 latest     93b5da182216   2 years ago         24.6MB
                                                                                  functions/hubstats                        latest     01affa91e9e4   2 years ago         29.3MB
                                                                                  functions/nodeinfo                        latest     2fe8a87bf79c   2 years ago         71.4MB
                                                                                  functions/alpine                          latest     46c6f6d74471   2 years ago         21.5MB
                                                                                  prom/prometheus                           v2.11.0    b97ed892eb23   2 years ago         126MB
                                                                                  prom/alertmanager                         v0.18.0    ce3c87f17369   2 years ago         51.9MB
                                                                                  alexellis2/openfaas-colorization          0.4.1      d36b67b1b5c1   2 years ago         1.84GB
                                                                                  rorpage/text-to-speech                    latest     5dc20810eb54   2 years ago         86.9MB
                                                                                  stefanprodan/faas-grafana                 4.6.3      2a4bd9caea50   4 years ago         284MB
                                                                                  
                                                                                  $ kubectl get pods --all-namespaces
                                                                                  NAMESPACE              NAME                                        READY   STATUS             RESTARTS        AGE
                                                                                  kube-system            coredns-64897985d-kp7vf                     1/1     Running            0               6d
                                                                                  kube-system            etcd-minikube                               1/1     Running            0               6d
                                                                                  kube-system            kube-apiserver-minikube                     1/1     Running            0               6d
                                                                                  kube-system            kube-controller-manager-minikube            1/1     Running            0               6d
                                                                                  kube-system            kube-proxy-5m8lr                            1/1     Running            0               6d
                                                                                  kube-system            kube-scheduler-minikube                     1/1     Running            0               6d
                                                                                  kube-system            storage-provisioner                         1/1     Running            1 (6d ago)      6d
                                                                                  kubernetes-dashboard   dashboard-metrics-scraper-58549894f-97tsv   1/1     Running            0               5d7h
                                                                                  kubernetes-dashboard   kubernetes-dashboard-ccd587f44-lkwcx        1/1     Running            0               5d7h
                                                                                  openfaas-fn            base64-6bdbcdb64c-djz8f                     1/1     Running            0               5d1h
                                                                                  openfaas-fn            colorise-85c74c686b-2fz66                   1/1     Running            0               4d5h
                                                                                  openfaas-fn            echoit-5d7df6684c-k6ljn                     1/1     Running            0               5d1h
                                                                                  openfaas-fn            env-6c79f7b946-bzbtm                        1/1     Running            0               4d5h
                                                                                  openfaas-fn            figlet-54db496f88-957xl                     1/1     Running            0               4d19h
                                                                                  openfaas-fn            hello-openfaas-547857b9d6-z277c             0/1     ImagePullBackOff   0               4d3h
                                                                                  openfaas-fn            hello-openfaas-7b6946b4f9-hcvq4             0/1     ImagePullBackOff   0               4d3h
                                                                                  openfaas-fn            hello-openfaas2-5c6f6cb5d9-24hkz            0/1     ImagePullBackOff   0               9m22s
                                                                                  openfaas-fn            hello-openfaas2-8957bb47b-7cgjg             0/1     ImagePullBackOff   0               2d22h
                                                                                  openfaas-fn            hello-openfaas3-65847b8b67-b94kd            0/1     ImagePullBackOff   0               4d2h
                                                                                  openfaas-fn            hello-python-6d6976845f-cwsln               0/1     ImagePullBackOff   0               3d19h
                                                                                  openfaas-fn            hello-python-b577cb8dc-64wf5                0/1     ImagePullBackOff   0               3d9h
                                                                                  openfaas-fn            hubstats-b6cd4dccc-z8tvl                    1/1     Running            0               5d1h
                                                                                  openfaas-fn            markdown-68f69f47c8-w5m47                   1/1     Running            0               5d1h
                                                                                  openfaas-fn            nodeinfo-d48cbbfcc-hfj79                    1/1     Running            0               5d1h
                                                                                  openfaas-fn            openfaas2-fun                               1/1     Running            0               15s
                                                                                  openfaas-fn            text-to-speech-74ffcdfd7-997t4              0/1     CrashLoopBackOff   2235 (3s ago)   4d5h
                                                                                  openfaas-fn            wordcount-6489865566-cvfzr                  1/1     Running            0               5d1h
                                                                                  openfaas               alertmanager-88449c789-fq2rg                1/1     Running            0               3d1h
                                                                                  openfaas               basic-auth-plugin-75fd7d69c5-zw4jh          1/1     Running            0               3d2h
                                                                                  openfaas               gateway-5c4bb7c5d7-n8h27                    2/2     Running            0               3d2h
                                                                                  openfaas               grafana                                     1/1     Running            0               4d8h
                                                                                  openfaas               nats-647b476664-hkr7p                       1/1     Running            0               3d2h
                                                                                  openfaas               prometheus-687648749f-tl8jp                 1/1     Running            0               3d1h
                                                                                  openfaas               queue-worker-7777ffd7f6-htx6t               1/1     Running            0               3d2h
                                                                                  
                                                                                  
                                                                                  $ kubectl get -o yaml -n openfaas-fn deploy/hello-openfaas2
                                                                                  apiVersion: apps/v1
                                                                                  kind: Deployment
                                                                                  metadata:
                                                                                    annotations:
                                                                                      deployment.kubernetes.io/revision: "6"
                                                                                      prometheus.io.scrape: "false"
                                                                                    creationTimestamp: "2022-03-17T12:47:35Z"
                                                                                    generation: 6
                                                                                    labels:
                                                                                      faas_function: hello-openfaas2
                                                                                    name: hello-openfaas2
                                                                                    namespace: openfaas-fn
                                                                                    resourceVersion: "400833"
                                                                                    uid: 9c4e9d26-23af-4f93-8538-4e2d96f0d7e0
                                                                                  spec:
                                                                                    progressDeadlineSeconds: 600
                                                                                    replicas: 1
                                                                                    revisionHistoryLimit: 10
                                                                                    selector:
                                                                                      matchLabels:
                                                                                        faas_function: hello-openfaas2
                                                                                    strategy:
                                                                                      rollingUpdate:
                                                                                        maxSurge: 1
                                                                                        maxUnavailable: 0
                                                                                      type: RollingUpdate
                                                                                    template:
                                                                                      metadata:
                                                                                        annotations:
                                                                                          prometheus.io.scrape: "false"
                                                                                        creationTimestamp: null
                                                                                        labels:
                                                                                          faas_function: hello-openfaas2
                                                                                          uid: "969512830"
                                                                                        name: hello-openfaas2
                                                                                      spec:
                                                                                        containers:
                                                                                        - env:
                                                                                          - name: fprocess
                                                                                            value: python3 index.py
                                                                                          image: wm/hello-openfaas2:0.1
                                                                                          imagePullPolicy: Always
                                                                                          livenessProbe:
                                                                                            failureThreshold: 3
                                                                                            httpGet:
                                                                                              path: /_/health
                                                                                              port: 8080
                                                                                              scheme: HTTP
                                                                                            initialDelaySeconds: 2
                                                                                            periodSeconds: 2
                                                                                            successThreshold: 1
                                                                                            timeoutSeconds: 1
                                                                                          name: hello-openfaas2
                                                                                          ports:
                                                                                          - containerPort: 8080
                                                                                            name: http
                                                                                            protocol: TCP
                                                                                          readinessProbe:
                                                                                            failureThreshold: 3
                                                                                            httpGet:
                                                                                              path: /_/health
                                                                                              port: 8080
                                                                                              scheme: HTTP
                                                                                            initialDelaySeconds: 2
                                                                                            periodSeconds: 2
                                                                                            successThreshold: 1
                                                                                            timeoutSeconds: 1
                                                                                          resources: {}
                                                                                          securityContext:
                                                                                            allowPrivilegeEscalation: false
                                                                                            readOnlyRootFilesystem: false
                                                                                          terminationMessagePath: /dev/termination-log
                                                                                          terminationMessagePolicy: File
                                                                                        dnsPolicy: ClusterFirst
                                                                                        enableServiceLinks: false
                                                                                        restartPolicy: Always
                                                                                        schedulerName: default-scheduler
                                                                                        securityContext: {}
                                                                                        terminationGracePeriodSeconds: 30
                                                                                  status:
                                                                                    conditions:
                                                                                    - lastTransitionTime: "2022-03-17T12:47:35Z"
                                                                                      lastUpdateTime: "2022-03-17T12:47:35Z"
                                                                                      message: Deployment does not have minimum availability.
                                                                                      reason: MinimumReplicasUnavailable
                                                                                      status: "False"
                                                                                      type: Available
                                                                                    - lastTransitionTime: "2022-03-20T12:16:56Z"
                                                                                      lastUpdateTime: "2022-03-20T12:16:56Z"
                                                                                      message: ReplicaSet "hello-openfaas2-5d6c7c7fb4" has timed out progressing.
                                                                                      reason: ProgressDeadlineExceeded
                                                                                      status: "False"
                                                                                      type: Progressing
                                                                                    observedGeneration: 6
                                                                                    replicas: 2
                                                                                    unavailableReplicas: 2
                                                                                    updatedReplicas: 1
                                                                                  

                                                                                  In one shell,

                                                                                  docker@minikube:~$ docker run  --name wm -ti wm/hello-openfaas2:0.1
                                                                                  2022/03/20 13:04:52 Version: 0.2.0  SHA: 56bf6aac54deb3863a690f5fc03a2a38e7d9e6ef
                                                                                  2022/03/20 13:04:52 Timeouts: read: 5s write: 5s hard: 0s health: 5s.
                                                                                  2022/03/20 13:04:52 Listening on port: 8080
                                                                                  ...
                                                                                  
                                                                                  

                                                                                  and another shell

                                                                                  docker@minikube:~$ docker ps | grep wm
                                                                                  d7796286641c   wm/hello-openfaas2:0.1             "fwatchdog"              3 minutes ago       Up 3 minutes (healthy)   8080/tcp   wm
                                                                                  

                                                                                  ANSWER

                                                                                  Answered 2022-Mar-16 at 08:10

                                                                                  If your image has a latest tag, the Pod's ImagePullPolicy will be automatically set to Always. Each time the pod is created, Kubernetes tries to pull the newest image.

                                                                                  Try not tagging the image as latest or manually setting the Pod's ImagePullPolicy to Never. If you're using static manifest to create a Pod, the setting will be like the following:

                                                                                  containers:
                                                                                    - name: test-container
                                                                                      image: testImage:latest
                                                                                      imagePullPolicy: Never
                                                                                  

                                                                                  Source https://stackoverflow.com/questions/71493306

                                                                                  QUESTION

                                                                                  IndexError: tuple index out of range when I try to create an executable from a python script using auto-py-to-exe
                                                                                  Asked 2022-Feb-24 at 15:03

                                                                                  I have been trying out an open-sourced personal AI assistant script. The script works fine but I want to create an executable so that I can gift the executable to one of my friends. However, when I try to create the executable using the auto-py-to-exe, it states the below error:

                                                                                  Running auto-py-to-exe v2.10.1
                                                                                  Building directory: C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x
                                                                                  Provided command: pyinstaller --noconfirm --onedir --console --no-embed-manifest  "C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py"
                                                                                  Recursion Limit is set to 5000
                                                                                  Executing: pyinstaller --noconfirm --onedir --console --no-embed-manifest C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py --distpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\application --workpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\build --specpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x
                                                                                  
                                                                                  42681 INFO: PyInstaller: 4.6
                                                                                  42690 INFO: Python: 3.10.0
                                                                                  42732 INFO: Platform: Windows-10-10.0.19042-SP0
                                                                                  42744 INFO: wrote C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\AI_Ass.spec
                                                                                  42764 INFO: UPX is not available.
                                                                                  42772 INFO: Extending PYTHONPATH with paths
                                                                                  ['C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310']
                                                                                  43887 INFO: checking Analysis
                                                                                  43891 INFO: Building Analysis because Analysis-00.toc is non existent
                                                                                  43895 INFO: Initializing module dependency graph...
                                                                                  43915 INFO: Caching module graph hooks...
                                                                                  43975 INFO: Analyzing base_library.zip ...
                                                                                  54298 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
                                                                                  54306 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib'
                                                                                  57474 INFO: Caching module dependency graph...
                                                                                  58088 INFO: running Analysis Analysis-00.toc
                                                                                  58132 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
                                                                                    required by C:\Users\Tarun\AppData\Local\Programs\Python\Python310\python.exe
                                                                                  58365 INFO: Analyzing C:\Users\Tarun\AppData\Local\Programs\Python\Python310\AI_Ass.py
                                                                                  59641 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
                                                                                  An error occurred while packaging
                                                                                  Traceback (most recent call last):
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\auto_py_to_exe\packaging.py", line 131, in package
                                                                                      run_pyinstaller()
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\__main__.py", line 124, in run
                                                                                      run_build(pyi_config, spec_file, **vars(args))
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\__main__.py", line 58, in run_build
                                                                                      PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py", line 782, in main
                                                                                      build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py", line 714, in build
                                                                                      exec(code, spec_namespace)
                                                                                    File "C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\AI_Ass.spec", line 7, in 
                                                                                      a = Analysis(['C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py'],
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py", line 277, in __init__
                                                                                      self.__postinit__()
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\datastruct.py", line 155, in __postinit__
                                                                                      self.assemble()
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py", line 439, in assemble
                                                                                      priority_scripts.append(self.graph.add_script(script))
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py", line 265, in add_script
                                                                                      self._top_script_node = super().add_script(pathname)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1433, in add_script
                                                                                      self._process_imports(n)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
                                                                                      target_module = self._safe_import_hook(*import_info, **kwargs)[0]
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2301, in _safe_import_hook
                                                                                      target_modules = self.import_hook(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1505, in import_hook
                                                                                      target_package, target_module_partname = self._find_head_package(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1684, in _find_head_package
                                                                                      target_package = self._safe_import_module(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py", line 387, in _safe_import_module
                                                                                      return super()._safe_import_module(module_basename, module_name, parent_package)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2062, in _safe_import_module
                                                                                      self._process_imports(n)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
                                                                                      target_module = self._safe_import_hook(*import_info, **kwargs)[0]
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2301, in _safe_import_hook
                                                                                      target_modules = self.import_hook(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1505, in import_hook
                                                                                      target_package, target_module_partname = self._find_head_package(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1684, in _find_head_package
                                                                                      target_package = self._safe_import_module(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py", line 387, in _safe_import_module
                                                                                      return super()._safe_import_module(module_basename, module_name, parent_package)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2062, in _safe_import_module
                                                                                      self._process_imports(n)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
                                                                                      target_module = self._safe_import_hook(*import_info, **kwargs)[0]
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2301, in _safe_import_hook
                                                                                      target_modules = self.import_hook(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1505, in import_hook
                                                                                      target_package, target_module_partname = self._find_head_package(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1684, in _find_head_package
                                                                                      target_package = self._safe_import_module(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py", line 387, in _safe_import_module
                                                                                      return super()._safe_import_module(module_basename, module_name, parent_package)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2062, in _safe_import_module
                                                                                      self._process_imports(n)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
                                                                                      target_module = self._safe_import_hook(*import_info, **kwargs)[0]
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2301, in _safe_import_hook
                                                                                      target_modules = self.import_hook(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1505, in import_hook
                                                                                      target_package, target_module_partname = self._find_head_package(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1684, in _find_head_package
                                                                                      target_package = self._safe_import_module(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py", line 387, in _safe_import_module
                                                                                      return super()._safe_import_module(module_basename, module_name, parent_package)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2062, in _safe_import_module
                                                                                      self._process_imports(n)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
                                                                                      target_module = self._safe_import_hook(*import_info, **kwargs)[0]
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2301, in _safe_import_hook
                                                                                      target_modules = self.import_hook(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1518, in import_hook
                                                                                      submodule = self._safe_import_module(head, mname, submodule)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py", line 387, in _safe_import_module
                                                                                      return super()._safe_import_module(module_basename, module_name, parent_package)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2062, in _safe_import_module
                                                                                      self._process_imports(n)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
                                                                                      target_module = self._safe_import_hook(*import_info, **kwargs)[0]
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2301, in _safe_import_hook
                                                                                      target_modules = self.import_hook(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1518, in import_hook
                                                                                      submodule = self._safe_import_module(head, mname, submodule)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py", line 387, in _safe_import_module
                                                                                      return super()._safe_import_module(module_basename, module_name, parent_package)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2062, in _safe_import_module
                                                                                      self._process_imports(n)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
                                                                                      target_module = self._safe_import_hook(*import_info, **kwargs)[0]
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2301, in _safe_import_hook
                                                                                      target_modules = self.import_hook(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1518, in import_hook
                                                                                      submodule = self._safe_import_module(head, mname, submodule)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py", line 387, in _safe_import_module
                                                                                      return super()._safe_import_module(module_basename, module_name, parent_package)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2061, in _safe_import_module
                                                                                      n = self._scan_code(module, co, co_ast)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2645, in _scan_code
                                                                                      self._scan_bytecode(
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2749, in _scan_bytecode
                                                                                      for inst in util.iterate_instructions(module_code_object):
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py", line 147, in iterate_instructions
                                                                                      yield from iterate_instructions(constant)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py", line 139, in iterate_instructions
                                                                                      yield from get_instructions(code_object)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\dis.py", line 338, in _get_instructions_bytes
                                                                                      argval, argrepr = _get_const_info(arg, constants)
                                                                                    File "C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\dis.py", line 292, in _get_const_info
                                                                                      argval = const_list[const_index]
                                                                                  IndexError: tuple index out of range
                                                                                  
                                                                                  Project output will not be moved to output folder
                                                                                  Complete.
                                                                                  

                                                                                  I understand that there is a thread already about similar issue but it still doesn't solve the issue. Hence seeking out help

                                                                                  I really have no idea why is the error occurring and how to resolve it. I am pasting the script below for your reference. Can some one please help? Thank you in advance

                                                                                  #importing libraries
                                                                                  
                                                                                  import speech_recognition as sr
                                                                                  import pyttsx3
                                                                                  import datetime
                                                                                  import wikipedia
                                                                                  import webbrowser
                                                                                  import os
                                                                                  import time
                                                                                  import subprocess
                                                                                  from   ecapture import ecapture as ec
                                                                                  import wolframalpha
                                                                                  import json
                                                                                  import requests
                                                                                  
                                                                                  #setting up speech engine
                                                                                  engine=pyttsx3.init('sapi5')
                                                                                  voices=engine.getProperty('voices')
                                                                                  engine.setProperty('voice','voices[1].id')
                                                                                  
                                                                                  def speak(text):
                                                                                      engine.say(text)
                                                                                      engine.runAndWait()
                                                                                      
                                                                                  #Greet user
                                                                                  def wishMe():
                                                                                      hour=datetime.datetime.now().hour
                                                                                      if hour>=0 and hour<12:
                                                                                          speak("Hello,Good Morning")
                                                                                          print("Hello,Good Morning")
                                                                                      elif hour>=12 and hour<18:
                                                                                          speak("Hello,Good Afternoon")
                                                                                          print("Hello,Good Afternoon")
                                                                                      else:
                                                                                          speak("Hello,Good Evening")
                                                                                          print("Hello,Good Evening")
                                                                                  
                                                                                  #Setting up the command function for your AI assistant
                                                                                  def takeCommand():
                                                                                      r=sr.Recognizer()
                                                                                      with sr.Microphone() as source:
                                                                                          print("Listening...")
                                                                                          audio=r.listen(source)
                                                                                  
                                                                                          try:
                                                                                              statement=r.recognize_google(audio,language='en-in')
                                                                                              print(f"user said:{statement}\n")
                                                                                  
                                                                                          except Exception as e:
                                                                                              speak("Pardon me, please say that again")
                                                                                              return "None"
                                                                                          return statement
                                                                                  
                                                                                  print("Loading your AI personal assistant Friday")
                                                                                  speak("Loading your AI personal assistant Friday")
                                                                                  wishMe()
                                                                                  
                                                                                  #main function
                                                                                  if __name__=='__main__':
                                                                                  
                                                                                  
                                                                                      while True:
                                                                                          speak("Tell me how can I help you now?")
                                                                                          statement = takeCommand().lower()
                                                                                          if statement==0:
                                                                                              continue
                                                                                  
                                                                                          if "good bye" in statement or "ok bye" in statement or "stop" in statement:
                                                                                              speak('your personal assistant Friday is shutting down,Good bye')
                                                                                              print('your personal assistant Friday is shutting down,Good bye')
                                                                                              break
                                                                                  
                                                                                  
                                                                                          if 'wikipedia' in statement:
                                                                                              speak('Searching Wikipedia...')
                                                                                              statement =statement.replace("wikipedia", "")
                                                                                              results = wikipedia.summary(statement, sentences=10)
                                                                                              webbrowser.open_new_tab("https://en.wikipedia.org/wiki/"+ statement)
                                                                                              speak("According to Wikipedia")
                                                                                              print(results)
                                                                                              speak(results)
                                                                                  
                                                                                          elif 'open youtube' in statement:
                                                                                              webbrowser.register('chrome', None,
                                                                                          webbrowser.BackgroundBrowser("C://Program Files (x86)//Google//Chrome//Application//chrome.exe"))
                                                                                              webbrowser.get('chrome').open_new_tab("https://www.youtube.com")
                                                                                              #webbrowser.open_new_tab("https://www.youtube.com")
                                                                                              speak("youtube is open now")
                                                                                              time.sleep(5)
                                                                                  
                                                                                          elif 'open google' in statement:
                                                                                              webbrowser.open_new_tab("https://www.google.com")
                                                                                              speak("Google chrome is open now")
                                                                                              time.sleep(5)
                                                                                  
                                                                                          elif 'open gmail' in statement:
                                                                                              webbrowser.open_new_tab("gmail.com")
                                                                                              speak("Google Mail open now")
                                                                                              time.sleep(5)
                                                                                          
                                                                                          elif 'time' in statement:
                                                                                              strTime=datetime.datetime.now().strftime("%H:%M:%S")
                                                                                              speak(f"the time is {strTime}")
                                                                                  
                                                                                          elif 'news' in statement:
                                                                                              news = webbrowser.open_new_tab("https://timesofindia.indiatimes.com/home/headlines")
                                                                                              speak('Here are some headlines from the Times of India,Happy reading')
                                                                                              time.sleep(6)
                                                                                  
                                                                                          elif "camera" in statement or "take a photo" in statement:
                                                                                              ec.capture(0,"robo camera","img.jpg")
                                                                                  
                                                                                          elif 'search' in statement:
                                                                                              statement = statement.replace("search", "")
                                                                                              webbrowser.open_new_tab(statement)
                                                                                              time.sleep(5)
                                                                                  
                                                                                          elif 'who are you' in statement or 'what can you do' in statement:
                                                                                              speak('I am Friday version 1 point O your personal assistant. I am programmed to minor tasks like'
                                                                                              'opening youtube,google chrome, gmail and stackoverflow ,predict time,take a photo,search wikipedia,predict weather' 
                                                                                              'In different cities, get top headline news from times of india and you can ask me computational or geographical questions too!')
                                                                                  
                                                                                  
                                                                                          elif "who made you" in statement or "who created you" in statement or "who discovered you" in statement:
                                                                                              speak("I was built by Mirthula")
                                                                                              print("I was built by Mirthula")
                                                                                  
                                                                                          elif "log off" in statement or "sign out" in statement:
                                                                                              speak("Ok , your pc will log off in 10 sec make sure you exit from all applications")
                                                                                              subprocess.call(["shutdown", "/l"])
                                                                                              
                                                                                  time.sleep(3)
                                                                                  

                                                                                  ANSWER

                                                                                  Answered 2021-Nov-05 at 02:20
                                                                                  42681 INFO: PyInstaller: 4.6
                                                                                  42690 INFO: Python: 3.10.0
                                                                                  

                                                                                  There's the issue. Python 3.10.0 has a bug with PyInstaller 4.6. The problem isn't you or PyInstaller. Try converting it using Python 3.9.7 instead. Ironic, considering 3.10.0 was suppose to be a bugfix update.

                                                                                  Source https://stackoverflow.com/questions/69776492

                                                                                  QUESTION

                                                                                  Google Actions Builder stops execution when selecting a visual item from a List
                                                                                  Asked 2022-Feb-23 at 15:32

                                                                                  I'm pulling my hairs here. I have a Google Assistant application that I build with Jovo 4 and Google Actions Builder.

                                                                                  The goal is to create a HelpScene, which shows some options that explain the possibilities/features of the app on selection. This is the response I return from my Webhook. (This is Jovo code, but doesn't matter as this returns a JSON when the Assistant calls the webhook.)

                                                                                  @Handle(GoogleAssistantHandles.onScene('HelpScene'))
                                                                                    showHelpList() {
                                                                                      return this.$send({
                                                                                        platforms: {
                                                                                          googleAssistant: {
                                                                                            nativeResponse: {
                                                                                              scene: {
                                                                                                name: this.jovo.$googleAssistant?.$request.scene?.name,
                                                                                                slots: {},
                                                                                                next: {
                                                                                                  name: 'MainScene',
                                                                                                },
                                                                                              },
                                                                                              session: {
                                                                                                id: 'session_id',
                                                                                                languageCode: 'nl-BE',
                                                                                                params: {},
                                                                                                typeOverrides: [
                                                                                                  {
                                                                                                    name: 'prompt_option',
                                                                                                    synonym: {
                                                                                                      entries: [
                                                                                                        {
                                                                                                          name: 'ITEM_1',
                                                                                                          synonyms: ['Item 1', 'First item'],
                                                                                                          display: {
                                                                                                            title: 'Item #1',
                                                                                                            description: 'Description of Item #1',
                                                                                                            image: {
                                                                                                              alt: 'Google Assistant logo',
                                                                                                              height: 0,
                                                                                                              url: 'https://developers.google.com/assistant/assistant_96.png',
                                                                                                              width: 0,
                                                                                                            },
                                                                                                          },
                                                                                                        },
                                                                                                        {
                                                                                                          name: 'ITEM_2',
                                                                                                          synonyms: ['Item 2', 'Second item'],
                                                                                                          display: {
                                                                                                            title: 'Item #2',
                                                                                                            description: 'Description of Item #2',
                                                                                                            image: {
                                                                                                              alt: 'Google Assistant logo',
                                                                                                              height: 0,
                                                                                                              url: 'https://developers.google.com/assistant/assistant_96.png',
                                                                                                              width: 0,
                                                                                                            },
                                                                                                          },
                                                                                                        },
                                                                                                        {
                                                                                                          name: 'ITEM_3',
                                                                                                          synonyms: ['Item 3', 'Third item'],
                                                                                                          display: {
                                                                                                            title: 'Item #3',
                                                                                                            description: 'Description of Item #3',
                                                                                                            image: {
                                                                                                              alt: 'Google Assistant logo',
                                                                                                              height: 0,
                                                                                                              url: 'https://developers.google.com/assistant/assistant_96.png',
                                                                                                              width: 0,
                                                                                                            },
                                                                                                          },
                                                                                                        },
                                                                                                        {
                                                                                                          name: 'ITEM_4',
                                                                                                          synonyms: ['Item 4', 'Fourth item'],
                                                                                                          display: {
                                                                                                            title: 'Item #4',
                                                                                                            description: 'Description of Item #4',
                                                                                                            image: {
                                                                                                              alt: 'Google Assistant logo',
                                                                                                              height: 0,
                                                                                                              url: 'https://developers.google.com/assistant/assistant_96.png',
                                                                                                              width: 0,
                                                                                                            },
                                                                                                          },
                                                                                                        },
                                                                                                      ],
                                                                                                    },
                                                                                                    typeOverrideMode: 'TYPE_REPLACE',
                                                                                                  },
                                                                                                ],
                                                                                              },
                                                                                              prompt: {
                                                                                                override: false,
                                                                                                content: {
                                                                                                  collection: {
                                                                                                    items: [
                                                                                                      {
                                                                                                        key: 'ITEM_1',
                                                                                                      },
                                                                                                      {
                                                                                                        key: 'ITEM_2',
                                                                                                      },
                                                                                                      {
                                                                                                        key: 'ITEM_3',
                                                                                                      },
                                                                                                      {
                                                                                                        key: 'ITEM_4',
                                                                                                      },
                                                                                                    ],
                                                                                                    subtitle: 'List subtitle',
                                                                                                    title: 'List title',
                                                                                                  },
                                                                                                },
                                                                                                firstSimple: {
                                                                                                  speech: 'This is a list.',
                                                                                                  text: 'This is a list.',
                                                                                                },
                                                                                              },
                                                                                            },
                                                                                          },
                                                                                        },
                                                                                      });
                                                                                  

                                                                                  I created a HelpScene which pulls my options from my webhook.

                                                                                  In my slot filling, this is the configuration.

                                                                                  When I use the simulator, the options from my webhook are shown perfectly. But when I click an item in the list, the app just stops working. "YourApp is currently not responding".

                                                                                  At first I thought it had something to do with my webhook, so I changed the behaviour of the "on slot is filled" condition, that it should prompt something, directly from Google Actions Builder, but the behaviour is still not desired: the app just stops working.

                                                                                  Any ideas what I'm doing wrong?

                                                                                  Thanks in advance!

                                                                                  ANSWER

                                                                                  Answered 2022-Feb-23 at 15:32

                                                                                  Okay, after days of searching, I finally figured it out. It did have something to do with the Jovo framework/setup and/or the scene parameter in the native response.

                                                                                  This is my component, in which I redirect new users to the HelpScene. This scene should show multiple cards in a list/collection/whatever on which the user can tap to receive more information about the application's features.

                                                                                  @Component()
                                                                                  export class WelcomeComponent extends BaseComponent {
                                                                                    async START(): Promise {
                                                                                      const isNewUser = true;
                                                                                      if (isNewUser && this.$device.supports(Capability.Screen)) {
                                                                                        return this.$send(NextSceneOutput, {
                                                                                          name: 'HelpScene',
                                                                                          message: 'Hi, I noticed you are a new user, let me walk you through some options.',
                                                                                        });
                                                                                      }
                                                                                  
                                                                                      return this.$send('Welcome!');
                                                                                    }
                                                                                  
                                                                                    @Handle(GoogleAssistantHandles.onScene('HelpScene'))
                                                                                    help() {
                                                                                      const sessionData = this.$request.getSession();
                                                                                      if (sessionData && sessionData.prompt_option) {
                                                                                        return this.$send(NextSceneOutput, {
                                                                                          name: 'MainScene',
                                                                                          message: `You picked option ${sessionData.prompt_option}. This is some info about it ... What do you want to do now?`,
                                                                                        });
                                                                                      }
                                                                                  
                                                                                      return this.$send({
                                                                                        platforms: {
                                                                                          googleAssistant: {
                                                                                            nativeResponse: {
                                                                                              session: {
                                                                                                id: 'session_id',
                                                                                                languageCode: '',
                                                                                                params: {},
                                                                                                typeOverrides: [
                                                                                                  {
                                                                                                    name: 'HelpOptionType',
                                                                                                    typeOverrideMode: 'TYPE_REPLACE',
                                                                                                    synonym: {
                                                                                                      entries: [
                                                                                                        {
                                                                                                          name: 'ITEM_1',
                                                                                                          synonyms: ['Item 1', 'First item'],
                                                                                                          display: {
                                                                                                            title: 'Item #1',
                                                                                                            description: 'Description of Item #1',
                                                                                                            image: {
                                                                                                              alt: 'Google Assistant logo',
                                                                                                              height: 0,
                                                                                                              url: 'https://developers.google.com/assistant/assistant_96.png',
                                                                                                              width: 0,
                                                                                                            },
                                                                                                          },
                                                                                                        },
                                                                                                        {
                                                                                                          name: 'ITEM_2',
                                                                                                          synonyms: ['Item 2', 'Second item'],
                                                                                                          display: {
                                                                                                            title: 'Item #2',
                                                                                                            description: 'Description of Item #2',
                                                                                                            image: {
                                                                                                              alt: 'Google Assistant logo',
                                                                                                              height: 0,
                                                                                                              url: 'https://developers.google.com/assistant/assistant_96.png',
                                                                                                              width: 0,
                                                                                                            },
                                                                                                          },
                                                                                                        },
                                                                                                        {
                                                                                                          name: 'ITEM_3',
                                                                                                          synonyms: ['Item 3', 'Third item'],
                                                                                                          display: {
                                                                                                            title: 'Item #3',
                                                                                                            description: 'Description of Item #3',
                                                                                                            image: {
                                                                                                              alt: 'Google Assistant logo',
                                                                                                              height: 0,
                                                                                                              url: 'https://developers.google.com/assistant/assistant_96.png',
                                                                                                              width: 0,
                                                                                                            },
                                                                                                          },
                                                                                                        },
                                                                                                        {
                                                                                                          name: 'ITEM_4',
                                                                                                          synonyms: ['Item 4', 'Fourth item'],
                                                                                                          display: {
                                                                                                            title: 'Item #4',
                                                                                                            description: 'Description of Item #4',
                                                                                                            image: {
                                                                                                              alt: 'Google Assistant logo',
                                                                                                              height: 0,
                                                                                                              url: 'https://developers.google.com/assistant/assistant_96.png',
                                                                                                              width: 0,
                                                                                                            },
                                                                                                          },
                                                                                                        },
                                                                                                      ],
                                                                                                    },
                                                                                                  },
                                                                                                ],
                                                                                              },
                                                                                              prompt: {
                                                                                                override: false,
                                                                                                content: {
                                                                                                  list: {
                                                                                                    items: [
                                                                                                      {
                                                                                                        key: 'ITEM_1',
                                                                                                      },
                                                                                                      {
                                                                                                        key: 'ITEM_2',
                                                                                                      },
                                                                                                      {
                                                                                                        key: 'ITEM_3',
                                                                                                      },
                                                                                                      {
                                                                                                        key: 'ITEM_4',
                                                                                                      },
                                                                                                    ],
                                                                                                    subtitle: 'List subtitle',
                                                                                                    title: 'List title',
                                                                                                  },
                                                                                                },
                                                                                                firstSimple: {
                                                                                                  speech: 'This is a list.',
                                                                                                  text: 'This is a list.',
                                                                                                },
                                                                                              },
                                                                                            },
                                                                                          },
                                                                                        },
                                                                                      });
                                                                                    }
                                                                                  
                                                                                    // ...other intents...
                                                                                  

                                                                                  In AoG I made 2 scenes, 1 MainScene on which a user enters the app and one HelpScene, which looks like this (yaml config). The goal of the HelpScene is only to be used for slot filling on the different options, then a user should go back to the MainScene.

                                                                                  "conditionalEvents":
                                                                                    - "condition": "scene.slots.status == \"FINAL\""
                                                                                      "handler":
                                                                                        "webhookHandler": "Jovo"
                                                                                  "slots":
                                                                                    - "commitBehavior":
                                                                                        "writeSessionParam": "prompt_option"
                                                                                      "name": "prompt_option"
                                                                                      "promptSettings":
                                                                                        "initialPrompt":
                                                                                          "webhookHandler": "Jovo"
                                                                                      "required": true
                                                                                      "type":
                                                                                        "name": "HelpOptionType"
                                                                                  

                                                                                  As you can see in my help() method, I just check if the session param is filled out. If it is, I redirect the user to the MainScene, but first give a response about the chosen option.

                                                                                  Source https://stackoverflow.com/questions/70968978

                                                                                  QUESTION

                                                                                  How to use muti-language in 'gTTS' for single input line?
                                                                                  Asked 2022-Jan-29 at 07:05

                                                                                  I want to convert text to speech from a document where multiple languages are included. When I am trying to do the following code, I fetch problems to record each language clearly. How can I save such type mixer text-audio clearly?

                                                                                  from gtts import gTTS
                                                                                  mytext = 'Welcome to gtts! আজ একটি ভাল দিন। tumi kemon acho? ٱلْحَمْدُ لِلَّٰهِ'
                                                                                  language = 'ar' # arabic
                                                                                  myobj = gTTS(text=mytext, tld='co.in', lang=language, slow=False)
                                                                                  myobj.save("audio.mp3")
                                                                                  

                                                                                  ANSWER

                                                                                  Answered 2022-Jan-29 at 07:05

                                                                                  It's not enough to use just text to speech, since it can work with one language only.
                                                                                  To solve this problem we need to detect language for each part of the sentence.
                                                                                  Then run it through text to speech and append it to our final spoken sentence.
                                                                                  It would be ideal to use some neural network (there are plenty) to do this categorization for You.
                                                                                  Just for a sake of proof of concept I used googletrans to detect language for each part of the sentences and gtts to make a mp3 file from it.

                                                                                  It's not bullet proof, especially with arabic text. googletrans somehow detect different language code, which is not recognized by gtts. For that reason we have to use code_table to pick proper language code that works with gtts.

                                                                                  Here is working example:

                                                                                  from googletrans import Translator
                                                                                  from gtts import gTTS
                                                                                  
                                                                                  input_text = "Welcome to gtts! আজ একটি ভাল দিন। tumi kemon acho? ٱلْحَمْدُ لِلَّٰه"
                                                                                  words = input_text.split(" ")
                                                                                  translator = Translator()
                                                                                  language, sentence = None, ""
                                                                                  
                                                                                  lang_code_table = {"sd": "ar"}
                                                                                  
                                                                                  with open('output.mp3', 'wb') as ff:
                                                                                      for word in words:
                                                                                          if word == " ":
                                                                                              continue
                                                                                          # Detect language of current word
                                                                                          word_language = translator.detect(word).lang
                                                                                  
                                                                                          if word_language == language:
                                                                                              # Same language, append word to the sentence
                                                                                              sentence += " " + word
                                                                                          else:
                                                                                              if language is None:
                                                                                                  # No language set yet, initialize and continue
                                                                                                  language, sentence = word_language, word
                                                                                                  continue
                                                                                  
                                                                                              if word.endswith(("?", ".", "!")):
                                                                                                  # If word endswith one of the punctuation marks, it should be part of previous sentence
                                                                                                  sentence += " " + word
                                                                                                  continue
                                                                                  
                                                                                              # We have whole previous sentence, translate it into speech and append to mp3 file
                                                                                              gTTS(text=sentence, lang=lang_code_table.get(language, language), slow=False).write_to_fp(ff)
                                                                                  
                                                                                              # Continue with other language
                                                                                              language, sentence = word_language, word
                                                                                  
                                                                                      if language and sentence:
                                                                                          # Append last detected sentence
                                                                                          gTTS(text=sentence, lang=lang_code_table.get(language, language), slow=False).write_to_fp(ff)
                                                                                  

                                                                                  It's obviously not fast and won't fit for longer text.
                                                                                  Also it needs better tokenizer and proper error handling.
                                                                                  Again, it's just proof of concept.

                                                                                  Source https://stackoverflow.com/questions/70852444

                                                                                  QUESTION

                                                                                  Assigning True/False if a token is present in a data-frame
                                                                                  Asked 2022-Jan-06 at 12:38

                                                                                  My current data-frame is:

                                                                                       |articleID | keywords                                               | 
                                                                                       |:-------- |:------------------------------------------------------:| 
                                                                                  0    |58b61d1d  | ['Second Avenue (Manhattan, NY)']                      |     
                                                                                  1    |58b6393b  | ['Crossword Puzzles']                                  |          
                                                                                  2    |58b6556e  | ['Workplace Hazards and Violations', 'Trump, Donald J']|            
                                                                                  3    |58b657fa  | ['Trump, Donald J', 'Speeches and Statements'].        |  
                                                                                  

                                                                                  I want a data-frame similar to the following, where a column is added based on whether a Trump token, 'Trump, Donald J' is mentioned in the keywords and if so then it is assigned True :

                                                                                       |articleID | keywords                                               | trumpMention |
                                                                                       |:-------- |:------------------------------------------------------:| ------------:|
                                                                                  0    |58b61d1d  | ['Second Avenue (Manhattan, NY)']                      | False        |      
                                                                                  1    |58b6393b  | ['Crossword Puzzles']                                  | False        |          
                                                                                  2    |58b6556e  | ['Workplace Hazards and Violations', 'Trump, Donald J']| True         |           
                                                                                  3    |58b657fa  | ['Trump, Donald J', 'Speeches and Statements'].        | True         |       
                                                                                  

                                                                                  I have tried multiple ways using df functions. But cannot achieve my wanted results. Some of the ways I've tried are:

                                                                                  df['trumpMention'] = np.where(any(df['keywords']) == 'Trump, Donald J', True, False) 
                                                                                  

                                                                                  or

                                                                                  df['trumpMention'] = df['keywords'].apply(lambda x: any(token == 'Trump, Donald J') for token in x) 
                                                                                  

                                                                                  or

                                                                                  lst = ['Trump, Donald J']  
                                                                                  df['trumpMention'] = df['keywords'].apply(lambda x: ([ True for token in x if any(token in lst)]))   
                                                                                  

                                                                                  Raw input:

                                                                                  df = pd.DataFrame({'articleID': ['58b61d1d', '58b6393b', '58b6556e', '58b657fa'],
                                                                                                     'keywords': [['Second Avenue (Manhattan, NY)'],
                                                                                                                  ['Crossword Puzzles'],
                                                                                                                  ['Workplace Hazards and Violations', 'Trump, Donald J'],
                                                                                                                  ['Trump, Donald J', 'Speeches and Statements']],
                                                                                                     'trumpMention': [False, False, True, True]})
                                                                                  

                                                                                  ANSWER

                                                                                  Answered 2022-Jan-06 at 12:13

                                                                                  try

                                                                                  df["trumpMention"] = df["keywords"].apply(lambda x: "Trump, Donald J" in x)
                                                                                  

                                                                                  Source https://stackoverflow.com/questions/70606847

                                                                                  QUESTION

                                                                                  speechSynthesis.getVoices (Web Speech API) doesn't show some of the locally installed voices
                                                                                  Asked 2021-Dec-31 at 08:19

                                                                                  I'm trying to use Web Speech API to read text on my web page. But I found that some of the SAPI5 voices installed in my Windows 10 would not show up in the output of speechSynthesis.getVoices(), including the Microsoft Eva Mobile on Windows 10 "unlock"ed by importing a registry file. These voices could work fine in local TTS programs like Balabolka but they just don't show in the browser. Are there any specific rules by which the browser chooses whether to list the voices or not?

                                                                                  ANSWER

                                                                                  Answered 2021-Dec-31 at 08:19

                                                                                  OK, I found out what was wrong. I was using Microsoft Edge and it seems that Edge only shows some of Microsoft voices. If I use Firefox, the other installed voices will also show up. So it was Edge's fault.

                                                                                  Source https://stackoverflow.com/questions/70490870

                                                                                  QUESTION

                                                                                  Combining Object Detection with Text to Speech Code
                                                                                  Asked 2021-Dec-28 at 16:46

                                                                                  I am trying to write an object detection + text-to-speech code to detect objects and produce a voice output on the raspberry pi 4. However, as of right now, I am trying to write a simple python script that incorporates both elements into a single .py file and preferably as a function. I will then run this script on the raspberry pi. I want to give credit to Murtaza's Workshop "Object Detection OpenCV Python | Easy and Fast (2020)" and https://pypi.org/project/pyttsx3/ for the Text to speech documentation for pyttsx3. I have attached the code below. I have tried running the program and I always keep getting errors with the Text to speech code (commented lines 33-36 for reference). I believe it is some looping error but I just can't seem to get the program to run continuously. For instance, if I run the code without the TTS part, it works fine. Otherwise, it runs for perhaps 3-5 seconds and suddenly stops. I am a beginner but highly passionate in computer vision, and any help is appreciated!

                                                                                  import cv2
                                                                                  #import pyttsx3
                                                                                  
                                                                                  cap = cv2.VideoCapture(0)
                                                                                  cap.set(3, 640)
                                                                                  cap.set(4, 480)
                                                                                  
                                                                                  classNames = []
                                                                                  classFile = 'coco.names'
                                                                                  with open(classFile,'rt') as f:
                                                                                      classNames = [line.rstrip() for line in f]
                                                                                  
                                                                                  configPath = 'ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt'
                                                                                  weightsPath = 'frozen_inference_graph.pb'
                                                                                  
                                                                                  net = cv2.dnn_DetectionModel(weightsPath, configPath)
                                                                                  net.setInputSize(320, 320)
                                                                                  net.setInputScale(1.0 / 127.5)
                                                                                  net.setInputMean((127.5, 127.5, 127.5))
                                                                                  net.setInputSwapRB(True)
                                                                                  
                                                                                  while True:
                                                                                      success, img = cap.read()
                                                                                      classIds, confs, bbox = net.detect(img, confThreshold=0.45)
                                                                                      if len(classIds) != 0:
                                                                                          for classId, confidence, box in zip(classIds.flatten(), confs.flatten(), bbox):
                                                                                              className = classNames[classId-1]
                                                                                              #engine = pyttsx3.init()
                                                                                              #str1 = str(className)
                                                                                              #engine.say(str1 + "detected")
                                                                                              #engine.runAndWait()
                                                                                              cv2.rectangle(img, box, color=(0, 255, 0), thickness=2)
                                                                                              cv2.putText(img, classNames[classId-1].upper(), (box[0]+10, box[1]+30),
                                                                                                  cv2.FONT_HERSHEY_COMPLEX, 1, (0, 255, 0), 2)
                                                                                              cv2.putText(img, str(round(confidence * 100, 2)), (box[0]+200, box[1]+30),
                                                                                                  cv2.FONT_HERSHEY_COMPLEX, 1, (0, 255, 0), 2)
                                                                                      cv2.imshow('Output', img)
                                                                                      cv2.waitKey(1)
                                                                                  

                                                                                  Here is a screenshot of my code 1

                                                                                  Here is a link to the download files needed to run code as well in case

                                                                                  Here is the error: /Users/venuchannarayappa/PycharmProjects/ObjectDetector/venv/bin/python /Users/venuchannarayappa/PycharmProjects/ObjectDetector/main.py

                                                                                  Traceback (most recent call last): File "/Users/venuchannarayappa/PycharmProjects/ObjectDetector/main.py", line 24, in

                                                                                  classIds, confs, bbox = net.detect(img, confThreshold=0.45)

                                                                                  cv2.error: OpenCV(4.5.4) /Users/runner/work/opencv-python/opencv-python/opencv/modules/imgproc/src/resize.cpp:4051: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

                                                                                  Process finished with exit code 1

                                                                                  Link to video output recorded through iphone: https://www.icloud.com/iclouddrive/03jGfqy7-A9DKfekcu3wjk0rA#IMG_4932

                                                                                  Sorry for such a long post! I was debugging my code for the past few hours and I think I got it to work. I changed the main while loop only and rest of code is the same. The program seems to run continuously for me. I would appreciate any comments if there are any difficulties in running it.

                                                                                  engine = pyttsx3.init()
                                                                                  while True:
                                                                                      success, img = cap.read()
                                                                                      #print(success)
                                                                                      #print(img)
                                                                                      #print(img.shape)
                                                                                      classIds, confs, bbox = net.detect(img, confThreshold=0.45)
                                                                                      if len(classIds) != 0:
                                                                                          for classId, confidence, box in zip(classIds.flatten(), confs.flatten(), bbox):
                                                                                              className = classNames[classId - 1]
                                                                                              #print(len(classIds))
                                                                                              str1 = str(className)
                                                                                              #print(str1)
                                                                                              engine.say(str1 + "detected")
                                                                                              engine.runAndWait()
                                                                                              cv2.rectangle(img, box, color=(0, 255, 0), thickness=2)
                                                                                              cv2.putText(img, classNames[classId-1].upper(), (box[0]+10, box[1]+30),
                                                                                                  cv2.FONT_HERSHEY_COMPLEX, 1, (0, 255, 0), 2)
                                                                                              cv2.putText(img, str(round(confidence * 100, 2)), (box[0]+200, box[1]+30),
                                                                                                  cv2.FONT_HERSHEY_COMPLEX, 1, (0, 255, 0), 2)
                                                                                          continue
                                                                                      cv2.imshow('Output', img)
                                                                                      cv2.waitKey(1)
                                                                                  

                                                                                  I am planning to run this code on the raspberry pi. I am planning on installing opencv using this command: pip3 install opencv-python. However, I am not sure how to install pyttsx3 since I think I need to install from source. Please let me know if there is a simple method to install pyttsx3.

                                                                                  Update: As of December 27th, I have installed all necessary packages and my code is now functional.

                                                                                  ANSWER

                                                                                  Answered 2021-Dec-28 at 16:46

                                                                                  I installed pyttsx3 using the two commands in the terminal on the Raspberry Pi:

                                                                                  1. sudo apt update && sudo apt install espeak ffmpeg libespeak1
                                                                                  2. pip install pyttsx3

                                                                                  I followed the video youtube.com/watch?v=AWhDDl-7Iis&ab_channel=AiPhile to install pyttsx3. My functional code should also be listed above. My question should be resolved but hopefully useful to anyone looking to write a similar program. I have made minor tweaks to my code.

                                                                                  Source https://stackoverflow.com/questions/70129247

                                                                                  QUESTION

                                                                                  Yielding values from consecutive parallel parse functions via meta in Scrapy
                                                                                  Asked 2021-Dec-20 at 07:53

                                                                                  In my scrapy code I'm trying to yield the following figures from parliament's website where all the members of parliament (MPs) are listed. Opening the links for each MP, I'm making parallel requests to get the figures I'm trying to count. I'm intending to yield each three figures below in the company of the name and the party of the MP

                                                                                  Here are the figures I'm trying to scrape

                                                                                  1. How many bill proposals that each MP has their signature on
                                                                                  2. How many question proposals that each MP has their signature on
                                                                                  3. How many times that each MP spoke on the parliament

                                                                                  In order to count and yield out how many bills has each member of parliament has their signature on, I'm trying to write a scraper on the members of parliament which works with 3 layers:

                                                                                  • Starting with the link where all MPs are listed
                                                                                  • From (1) accessing the individual page of each MP where the three information defined above is displayed
                                                                                  • 3a) Requesting the page with bill proposals and counting the number of them by len function 3b) Requesting the page with question proposals and counting the number of them by len function 3c) Requesting the page with speeches and counting the number of them by len function

                                                                                  What I want: I want to yield the inquiries of 3a,3b,3c with the name and the party of the MP in the same raw

                                                                                  • Problem 1) When I get an output to csv it only creates fields of speech count, name, part. It doesn't show me the fields of bill proposals and question proposals

                                                                                  • Problem 2) There are two empty values for each MP, which I guess corresponds to the values I described above at Problem1

                                                                                  • Problem 3) What is the better way of restructuring my code to output the three values in the same line, rather than printing each MP three times for each value that I'm scraping

                                                                                  from scrapy import Spider
                                                                                  from scrapy.http import Request
                                                                                  
                                                                                  import logging
                                                                                  
                                                                                  
                                                                                  class MvSpider(Spider):
                                                                                      name = 'mv2'
                                                                                      allowed_domains = ['tbmm.gov.tr']
                                                                                      start_urls = ['https://www.tbmm.gov.tr/Milletvekilleri/liste']
                                                                                  
                                                                                      def parse(self, response):
                                                                                          mv_list =  mv_list = response.xpath("//ul[@class='list-group list-group-flush']") #taking all MPs listed
                                                                                  
                                                                                          for mv in mv_list:
                                                                                              name = mv.xpath("./li/div/div/a/text()").get() # MP's name taken
                                                                                              party = mv.xpath("./li/div/div[@class='col-md-4 text-right']/text()").get().strip() #MP's party name taken
                                                                                              partial_link = mv.xpath('.//div[@class="col-md-8"]/a/@href').get()
                                                                                              full_link = response.urljoin(partial_link)
                                                                                  
                                                                                              yield Request(full_link, callback = self.mv_analysis, meta = {
                                                                                                                                                              'name': name,
                                                                                                                                                              'party': party
                                                                                                                                                          })
                                                                                  
                                                                                  
                                                                                      def mv_analysis(self, response):
                                                                                          name = response.meta.get('name')
                                                                                          party = response.meta.get('party')
                                                                                  
                                                                                          billprop_link_path = response.xpath(".//a[contains(text(),'İmzası Bulunan Kanun Teklifleri')]/@href").get()
                                                                                          billprop_link = response.urljoin(billprop_link_path)
                                                                                  
                                                                                          questionprop_link_path = response.xpath(".//a[contains(text(),'Sahibi Olduğu Yazılı Soru Önergeleri')]/@href").get()
                                                                                          questionprop_link = response.urljoin(questionprop_link_path)
                                                                                  
                                                                                          speech_link_path = response.xpath(".//a[contains(text(),'Genel Kurul Konuşmaları')]/@href").get()
                                                                                          speech_link = response.urljoin(speech_link_path)
                                                                                  
                                                                                          yield Request(billprop_link, callback = self.bill_prop_counter, meta = {
                                                                                                                                                              'name': name,
                                                                                                                                                              'party': party
                                                                                                                                                          })  #number of bill proposals to be requested
                                                                                  
                                                                                          yield Request(questionprop_link, callback = self.quest_prop_counter, meta = {
                                                                                                                                                              'name': name,
                                                                                                                                                              'party': party
                                                                                                                                                          }) #number of question propoesals to be requested
                                                                                  
                                                                                  
                                                                                          yield Request(speech_link, callback = self.speech_counter, meta = {
                                                                                                                                                              'name': name,
                                                                                                                                                              'party': party
                                                                                                                                                          })  #number of speeches to be requested
                                                                                  
                                                                                  
                                                                                  
                                                                                  
                                                                                  # COUNTING FUNCTIONS
                                                                                  
                                                                                  
                                                                                      def bill_prop_counter(self,response):
                                                                                  
                                                                                          name = response.meta.get('name')
                                                                                          party = response.meta.get('party')
                                                                                  
                                                                                          billproposals = response.xpath("//tr[@valign='TOP']")
                                                                                  
                                                                                          yield  { 'bill_prop_count': len(billproposals),
                                                                                                  'name': name,
                                                                                                  'party': party}
                                                                                  
                                                                                      def quest_prop_counter(self, response):
                                                                                  
                                                                                          name = response.meta.get('name')
                                                                                          party = response.meta.get('party')
                                                                                  
                                                                                          researchproposals = response.xpath("//tr[@valign='TOP']")
                                                                                  
                                                                                          yield {'res_prop_count': len(researchproposals),
                                                                                                 'name': name,
                                                                                                 'party': party}
                                                                                  
                                                                                      def speech_counter(self, response):
                                                                                  
                                                                                          name = response.meta.get('name')
                                                                                          party = response.meta.get('party')
                                                                                  
                                                                                          speeches = response.xpath("//tr[@valign='TOP']")
                                                                                  
                                                                                          yield { 'speech_count' : len(speeches),
                                                                                                 'name': name,
                                                                                                 'party': party}
                                                                                  

                                                                                  ANSWER

                                                                                  Answered 2021-Dec-18 at 06:26

                                                                                  This is happening because you are yielding dicts instead of item objects, so spider engine will not have a guide of fields you want to have as default.

                                                                                  In order to make the csv output fields bill_prop_count and res_prop_count, you should make the following changes in your code:

                                                                                  1 - Create a base item object with all desirable fields - you can create this in the items.py file of your scrapy project:

                                                                                  from scrapy import Item, Field
                                                                                  
                                                                                  
                                                                                  class MvItem(Item):
                                                                                      name = Field()
                                                                                      party = Field()
                                                                                      bill_prop_count = Field()
                                                                                      res_prop_count = Field()
                                                                                      speech_count = Field()
                                                                                  

                                                                                  2 - Import the item object created to the spider code & yield items populated with the dict, instead of single dicts:

                                                                                  from your_project.items import MvItem
                                                                                  
                                                                                  ...
                                                                                  
                                                                                  # COUNTING FUNCTIONS
                                                                                  def bill_prop_counter(self,response):
                                                                                      name = response.meta.get('name')
                                                                                      party = response.meta.get('party')
                                                                                  
                                                                                      billproposals = response.xpath("//tr[@valign='TOP']")
                                                                                  
                                                                                      yield MvItem(**{ 'bill_prop_count': len(billproposals),
                                                                                              'name': name,
                                                                                              'party': party})
                                                                                  
                                                                                  def quest_prop_counter(self, response):
                                                                                      name = response.meta.get('name')
                                                                                      party = response.meta.get('party')
                                                                                  
                                                                                      researchproposals = response.xpath("//tr[@valign='TOP']")
                                                                                  
                                                                                      yield MvItem(**{'res_prop_count': len(researchproposals),
                                                                                             'name': name,
                                                                                             'party': party})
                                                                                  
                                                                                  def speech_counter(self, response):
                                                                                      name = response.meta.get('name')
                                                                                      party = response.meta.get('party')
                                                                                  
                                                                                      speeches = response.xpath("//tr[@valign='TOP']")
                                                                                  
                                                                                      yield MvItem(**{ 'speech_count' : len(speeches),
                                                                                             'name': name,
                                                                                             'party': party})
                                                                                  

                                                                                  The output csv will have all possible columns for the item:

                                                                                  bill_prop_count,name,party,res_prop_count,speech_count
                                                                                  ,Abdullah DOĞRU,AK Parti,,11
                                                                                  ,Mehmet Şükrü ERDİNÇ,AK Parti,,3
                                                                                  ,Muharrem VARLI,MHP,,13
                                                                                  ,Muharrem VARLI,MHP,0,
                                                                                  ,Jülide SARIEROĞLU,AK Parti,,3
                                                                                  ,İbrahim Halil FIRAT,AK Parti,,7
                                                                                  20,Burhanettin BULUT,CHP,,
                                                                                  ,Ünal DEMİRTAŞ,CHP,,22
                                                                                  ...
                                                                                  

                                                                                  Now if you want to have all the three counts in the same row, you'll have to change the design of your spider. Possibly one counting function at the time passing the item in the meta attribute.

                                                                                  Source https://stackoverflow.com/questions/70399191

                                                                                  QUESTION

                                                                                  Rails. Puma stops working when instantiating a client of Google Cloud Text-to-Speech (Windows)
                                                                                  Asked 2021-Dec-15 at 22:07

                                                                                  I've upgraded my Ruby version from 2.5.x to 2.6.x (and uninstalled the 2.5.x version). And now Puma server stops working when instantiating a client of Google Cloud Text-to-Speech:

                                                                                  client = Google::Cloud::TextToSpeech.text_to_speech
                                                                                  

                                                                                  It just exits without giving an error (in Command Prompt). And there is a 'Segmentation fault' message in the 'bash' terminal.

                                                                                  Puma config-file:

                                                                                  max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
                                                                                  min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
                                                                                  threads min_threads_count, max_threads_count
                                                                                  port        ENV.fetch("PORT") { 3000 }
                                                                                  environment ENV.fetch("RAILS_ENV") { ENV['RACK_ENV'] || "development" }
                                                                                  pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
                                                                                  # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
                                                                                  preload_app!
                                                                                  plugin :tmp_restart
                                                                                  

                                                                                  The method that works with Google Cloud Text-to-Speech:

                                                                                  require "google/cloud/text_to_speech"
                                                                                  
                                                                                  # Instantiates a client
                                                                                  client = Google::Cloud::TextToSpeech.text_to_speech
                                                                                    
                                                                                  ...
                                                                                  

                                                                                  Gemfile:

                                                                                  gem 'rails',                       '6.0.1'
                                                                                  gem 'puma',                        '3.12.2'
                                                                                  gem 'google-cloud-text_to_speech', '1.1.1'
                                                                                  ...
                                                                                  

                                                                                  OS Windows 10.

                                                                                  I'm confused. I don't understand why it happens and how to fix it. I've tried to use the last gem-versions for 'puma' and 'google-cloud-text_to_speech', reinstalled the Google SDK, but it continues happening.

                                                                                  Maybe something's wrong with my credentials? I get the nil value when running the configure method (before instantiating the client):

                                                                                  (byebug) Google::Cloud::TextToSpeech.configure
                                                                                  
                                                                                  

                                                                                  Can somebody please help me?

                                                                                  ANSWER

                                                                                  Answered 2021-Dec-07 at 08:52

                                                                                  Try reinstalling ruby-debug

                                                                                  sudo gem uninstall ruby-debug
                                                                                  sudo gem install ruby-debug
                                                                                  

                                                                                  And, can you expand your question with including your Gemfile, and Gemfile.lock

                                                                                  Another aproach may be deleting Gemfile.lock then running bundle install

                                                                                  rm -rf Gemfile.lock
                                                                                  bundle install
                                                                                  

                                                                                  Source https://stackoverflow.com/questions/70173479

                                                                                  QUESTION

                                                                                  R - Regular Expression to Extract Text Between Parentheses That Contain Keyword
                                                                                  Asked 2021-Nov-13 at 22:41

                                                                                  I need to extract the text from between parentheses if a keyword is inside the parentheses.

                                                                                  So if I have a string that looks like this:

                                                                                  ('one', 'CARDINAL'), ('Castro', 'PERSON'), ('Latin America', 'LOC'), ('Somoza', 'PERSON')

                                                                                  And my keyword is "LOC", I just want to extract ('Latin America', 'LOC'), not the others.

                                                                                  Help is appreciated!!

                                                                                  This is a sample of my data set, a csv file:

                                                                                  ,speech_id,sentence,date,speaker,file,parsed_text,named_entities
                                                                                  0,950094636,Let me state that the one sure way we can make it easy for Castro to continue to gain converts in Latin America is if we continue to support regimes of the ilk of the Somoza family,19770623,Mr. OBEY,06231977.txt,Let me state that the one sure way we can make it easy for Castro to continue to gain converts in Latin America is if we continue to support regimes of the ilk of the Somoza family,"[('one', 'CARDINAL'), ('Castro', 'PERSON'), ('Latin America', 'LOC'), ('Somoza', 'PERSON')]"
                                                                                  1,950094636,That is how we encourage the growth of communism,19770623,Mr. OBEY,06231977.txt,That is how we encourage the growth of communism,[]
                                                                                  2,950094636,That is how we discourage the growth of democracy in Latin America,19770623,Mr. OBEY,06231977.txt,That is how we discourage the growth of democracy in Latin America,"[('Latin America', 'LOC')]"
                                                                                  3,950094636,Mr Chairman,19770623,Mr. OBEY,06231977.txt,Mr Chairman,[]
                                                                                  4,950094636,given the speeches I have made lately about the press,19770623,Mr. OBEY,06231977.txt,given the speeches I have made lately about the press,[]
                                                                                  5,950094636,I am not one,19770623,Mr. OBEY,06231977.txt,I am not one,[]
                                                                                  6,950094636,I suppose,19770623,Mr. OBEY,06231977.txt,I suppose,[]
                                                                                  

                                                                                  I am trying to extract just parentheses with the word LOC:

                                                                                  regex <- "(?=\\().*? \'LOC.*?(?<=\\))"
                                                                                    
                                                                                    
                                                                                  filtered_df$clean_NE <- str_extract_all(filtered_df$named_entities, regex)
                                                                                  

                                                                                  The above regular expression does not work. Thanks!

                                                                                  ANSWER

                                                                                  Answered 2021-Nov-13 at 22:41

                                                                                  You can use

                                                                                  str_extract_all(filtered_df$named_entities, "\\([^()]*'LOC'[^()]*\\)")
                                                                                  

                                                                                  See the regex demo. Details:

                                                                                  • \( - a ( char
                                                                                  • [^()]* - zero or more chars other than ( and )
                                                                                  • 'LOC' - a 'LOC' string
                                                                                  • [^()]* - zero or more chars other than ( and )
                                                                                  • \) - a ) char.

                                                                                  See the online R demo:

                                                                                  library(stringr)
                                                                                  x <- "[('one', 'CARDINAL'), ('Castro', 'PERSON'), ('Latin America', 'LOC'), ('Somoza', 'PERSON')]"
                                                                                  str_extract_all(x, "\\([^()]*'LOC'[^()]*\\)")
                                                                                  # => [1] "('Latin America', 'LOC')"
                                                                                  

                                                                                  As a bonus solution to get Latin America, you can use

                                                                                  str_extract_all(x, "[^']+(?=',\\s*'LOC'\\))")
                                                                                  # => [1] "Latin America"
                                                                                  

                                                                                  Here, [^']+(?=',\s*'LOC'\)) matches one or more chars other than ' that are followed with ',, zero or more whitespaces, and then 'LOC') string.

                                                                                  Source https://stackoverflow.com/questions/69958102

                                                                                  Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                  Vulnerabilities

                                                                                  No vulnerabilities reported

                                                                                  Install Resemblyzer

                                                                                  You can install using 'pip install Resemblyzer' or download it from GitHub, PyPI.
                                                                                  You can use Resemblyzer like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

                                                                                  Support

                                                                                  For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
                                                                                  Find more information at:
                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit
                                                                                  Install
                                                                                • PyPI

                                                                                  pip install Resemblyzer

                                                                                • CLONE
                                                                                • HTTPS

                                                                                  https://github.com/resemble-ai/Resemblyzer.git

                                                                                • CLI

                                                                                  gh repo clone resemble-ai/Resemblyzer

                                                                                • sshUrl

                                                                                  git@github.com:resemble-ai/Resemblyzer.git

                                                                                • Share this Page

                                                                                  share link

                                                                                  Consider Popular Speech Libraries

                                                                                  DeepSpeech

                                                                                  by mozilla

                                                                                  kaldi

                                                                                  by kaldi-asr

                                                                                  zeal

                                                                                  by zealdocs

                                                                                  leon

                                                                                  by leon-ai

                                                                                  Try Top Libraries by resemble-ai

                                                                                  MelNet

                                                                                  by resemble-aiPython

                                                                                  resemble-alexa

                                                                                  by resemble-aiPython

                                                                                  Compare Speech Libraries with Highest Support

                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit